Docstoc

Hello - Get Now PowerPoint

Document Sample
Hello - Get Now PowerPoint Powered By Docstoc
					Ch4: Software Architecture and Design
   Modules: Interface vs. Implementation (contd..)

 Interface design considerations:




                                                     1
Module: Interface vs. Implementation (contd..)


    Symbol table
                   GET(Varname) returns (int,POS)
                                                 Retrieve value

                   PUT(Varname,value) returns POS
                                                    Store new value
                   CREATE(Varname,size)
                                                 New entry creation
                                                 size = #of entries
                                                 it represents




                                                                      2
   Module: Interface vs. Implementation (contd..)

 Module symbol table hides:




                                                    3
   Modules: Interface vs. implementation (contd..)

 Support for prototyping:




                                                     4
   Modules: Interface vs. Implementation (contd..)

 Separation of interface and implementation supports
  information hiding:




                                                        5
   Modules: Interface vs. Implementation (contd..)

 Secrets that may be hidden in the module:
      How the algorithm works (quicksort, bubble sort, etc.)
      Data formats (Binary, ASCII, etc.)
      Data structure (linked list, array etc.)
      User interfaces (AWT)
      Texts (language specific grammars, spellings, etc.)
      Details of interfacing with input/output devices




                                                                6
Modules: Interface vs. Implementation (contd..)


              File I/O module
                 openFile()
                 closeFile()
                 readFile()




  Unix O/S      Windows O/S      AIX O/S




                                                  7
Advantages of modular designs




                                8
   Properties of modular designs

 Cohesion:




 Coupling:




                                   9
   Top-down design strategy




General                       Specific




                                     10
 Bottom-up design strategy




Pieces                       Compose




                                       11
   Top-down vs. bottom-up design strategy

 Which choice is better?




 How should documentation be structured?




                                            12
      IS_COMPONENT_OF revisited


 M M M           M    M                             M1
  7 8 9           5    6


          M2     M3    M4
                                             M2     M3      M4


                 M1                  M M M          M     M
                                      7 8 9          5     6

      (IS_COMPONENT_OF)                     (COMPRISES)
What design strategy do the relations IS_COMPONENT_OF & COMPRISES
depict?

                                                               13
   Design notation

 Why do we need a design notation?




 What are the different types of design notation?




                                                     14
   Textual Design Notation (TDN)

 Textual design notation loosely based on Ada
 Interface description
      Module may export:




      Comments are used to describe




                                                 15
   TDN (contd..)

module X
uses Y, Z
exports var A : integer;
        type B : array (1. .10) of real;
        procedure C ( D: in out B; E: in integer; F: in real);
        Here is an optional natural-language description of what
        A, B, and C actually are, along with possible constraints
         or properties that clients need to know; for example, we
        might specify that objects of type B sent to procedure C
        should be initialized by the client and should never
        contain all zeroes.
implementation
        If needed, here are general comments about the rationale
        of the modularization, hints on the implementation, etc.
        is composed of R, T
end X

                                                                16
   TDN (contd..)

 Uses




 Implementation




 An entity E exported by module M is denoted by M.E




                                                       17
  TDN (contd..)

                          X
                   Y
                              R

                              T
                   X



•Export section:



•Consistency and completeness analysis:




                                          18
  Graphical design notation (GDN)

Graphical notation:




      Module X
                          Module Y


   Module        Module
     R             T




                          Module Z
  A         B      C



                                     19
   Categories of modules

 Advantages of categorization into modules:




 Categories of modules:




                                               20
   Categories of modules: Standard categories

 Functional modules:




 Libraries:




 Common pools of data:




                                                21
   Categories of modules (contd..)

 Abstract objects




 Abstract data types




                                     22
    Abstract objects

 What is an abstract object:




 Difference between an abstract object and a library module:




                                                                23
   Abstract objects

 Example of an abstract object: stack




                                         24
       Abstract objects (contd..)


                   Public
                 Interface   Private Implementation

                             Head: Int;
          User                                             Designer
                             ST: Array[100] of Int;
                    PUSH
                    POP      Push(X Int)
                             …
                    TOP      End;
                    EMPTY
                             Int Pop()
                             …
                             End;



PUSH
            5                 20 15   10      5
           10                                                  ST
           15       5
                    TOP       20         15       10   5
           20



                                                                      25
   Motivating ADTs

 All built in types are ADTs




 Use of ADTs:




                                26
   Motivating ADTs (contd..)

 Applications may require multiple abstract objects of one
  “type”.




 Abstract data types (ADTs) introduced to address these
  issues.




                                                              27
ADT definition




                 28
   ADT examples

 Set:



 Multiset:



 Sequence:



 Graph:




                  29
      Abstract data types: Stack example

                           Stack ADT

                                    indicates that details of the
                                    data structure are hidden
module STACK_HANDLER                to clients
exports
        type STACK = ?;
        This is an abstract data-type module; the data structure
        is a secret hidden in the implementation part.
        procedure PUSH (S: in out STACK ; VAL: in integer);
        procedure POP (S: in out STACK ; VAL: out integer);
        function EMPTY (S: in STACK) : BOOLEAN;
        .
        .
        .
end STACK_HANDLER

                                                                    30
Abstract objects vs. ADTs

     O                                    O
            STACK                             STACK of
     K                                    K
                                              chars




Module object
Single instance
                         T                I        G
Has state
                         H                S        O
                         I                         O
                         S                         D


                     Multiple instances
                     ADT has no state
                     Stack S1, S2, S3;
                                                       31
   Abstract data types: Summary

 Proposed by B. Liskov (MIT) in 1975
 Abstract data type:




 ADTs and OO




                                        32

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:10
posted:12/4/2010
language:English
pages:33