330 likes | 489 Views
Ch4: Software Architecture and Design. Modules: Interface vs. Implementation (contd..). Interface design considerations:. Module: Interface vs. Implementation (contd..). Symbol table. GET(Varname) returns (int,POS). Retrieve value. PUT(Varname,value) returns POS. Store new value.
E N D
Modules: Interface vs. Implementation (contd..) • Interface design considerations:
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
Module: Interface vs. Implementation (contd..) • Module symbol table hides:
Modules: Interface vs. implementation (contd..) • Support for prototyping:
Modules: Interface vs. Implementation (contd..) • Separation of interface and implementation supports information hiding:
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
Modules: Interface vs. Implementation (contd..) File I/O module openFile() closeFile() readFile() Unix O/S Windows O/S AIX O/S
Properties of modular designs • Cohesion: • Coupling:
Top-down design strategy General Specific
Bottom-up design strategy Pieces Compose
Top-down vs. bottom-up design strategy • Which choice is better? • How should documentation be structured?
M M M M M M 6 8 9 5 1 7 M M M 3 4 2 M M M 4 2 3 M M M M M M 1 6 8 9 5 7 (IS_COMPONENT_OF) (COMPRISES) IS_COMPONENT_OF revisited What design strategy do the relations IS_COMPONENT_OF & COMPRISES depict?
Design notation • Why do we need a design notation? • What are the different types of design notation?
Textual Design Notation (TDN) • Textual design notation loosely based on Ada • Interface description • Module may export: • Comments are used to describe
TDN (contd..) • Uses • Implementation • An entity E exported by module M is denoted by M.E
R Y X TDN (contd..) X T • Export section: • Consistency and completeness analysis:
Graphical design notation (GDN) Graphical notation: Module X Module Y Module Module R T Module Z C B B A
Categories of modules • Advantages of categorization into modules: • Categories of modules:
Categories of modules: Standard categories • Functional modules: • Libraries: • Common pools of data:
Categories of modules (contd..) • Abstract objects • Abstract data types
Abstract objects • What is an abstract object: • Difference between an abstract object and a library module:
Abstract objects • Example of an abstract object: stack
Public Interface User PUSH POP TOP EMPTY Abstract objects (contd..) Private Implementation Head: Int; ST: Array[100] of Int; Push(X Int) … End; Int Pop() … End; Designer PUSH 15 20 10 5 5 10 ST 15 5 20 15 5 TOP 10 20
Motivating ADTs • All built in types are ADTs • Use of ADTs:
Motivating ADTs (contd..) • Applications may require multiple abstract objects of one “type”. • Abstract data types (ADTs) introduced to address these issues.
ADT examples • Set: • Multiset: • Sequence: • Graph:
Abstract data types: Stack example Stack ADT indicates that details of the data structure are hidden to clients
Abstract objects vs. ADTs O O STACK of chars STACK K K Module object Single instance Has state T I G H S O O I D S Multiple instances ADT has no state Stack S1, S2, S3;
Abstract data types: Summary • Proposed by B. Liskov (MIT) in 1975 • Abstract data type: • ADTs and OO