Top Banner
Ch4: Software Architecture and Design
33

Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..) Interface design considerations:

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

Ch4: Software Architecture and Design

Page 2: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

2

Modules: Interface vs. Implementation (contd..)

Interface design considerations:

Page 3: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

3

Module: Interface vs. Implementation (contd..)

Symbol tableGET(Varname) returns (int,POS)

PUT(Varname,value) returns POS

CREATE(Varname,size)

Retrieve value

Store new value

New entry creationsize = #of entriesit represents

Page 4: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

4

Module: Interface vs. Implementation (contd..)

Module symbol table hides:

Page 5: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

5

Modules: Interface vs. implementation (contd..)

Support for prototyping:

Page 6: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

6

Modules: Interface vs. Implementation (contd..)

Separation of interface and implementation supports information hiding:

Page 7: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

7

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

Page 8: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

8

Modules: Interface vs. Implementation (contd..)

openFile()closeFile()readFile()

File I/O module

Unix O/S AIX O/SWindows O/S

Page 9: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

9

Advantages of modular designs

Page 10: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

10

Properties of modular designs

Cohesion:

Coupling:

Page 11: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

11

Top-down design strategy

General Specific

Page 12: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

12

Bottom-up design strategy

Pieces Compose

Page 13: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

13

Top-down vs. bottom-up design strategy

Which choice is better?

How should documentation be structured?

Page 14: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

14

IS_COMPONENT_OF revisited

M1

M M

M MM M M

2 4

5 67 8 9

M3

M MM M M5 67 8 9

M2 M3 M4

M1

(IS_COMPONENT_OF) (COMPRISES)

What design strategy do the relations IS_COMPONENT_OF & COMPRISESdepict?

Page 15: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

15

Design notation

Why do we need a design notation?

What are the different types of design notation?

Page 16: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

16

Textual Design Notation (TDN)

Textual design notation loosely based on Ada Interface description

Module may export:

Comments are used to describe

Page 17: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

17

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

Page 18: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

18

TDN (contd..)

Uses

Implementation

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

Page 19: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

19

TDN (contd..)

R

T

Y

X

X

•Export section:

•Consistency and completeness analysis:

Page 20: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

20

Graphical design notation (GDN)

Graphical notation:

Y

Z Module

Module

X

A

B

R T Module Module

Module

C

B

Page 21: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

21

Categories of modules

Advantages of categorization into modules:

Categories of modules:

Page 22: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

22

Categories of modules: Standard categories

Functional modules:

Libraries:

Common pools of data:

Page 23: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

23

Categories of modules (contd..)

Abstract objects

Abstract data types

Page 24: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

24

Abstract objects

What is an abstract object:

Difference between an abstract object and a library module:

Page 25: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

25

Abstract objects

Example of an abstract object: stack

Page 26: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

26

Abstract objects (contd..)

PublicInterface

User

PUSHPOPTOPEMPTY

Private Implementation

DesignerHead: Int;ST: Array[100] of Int;

Push(X Int)…End;

Int Pop()…End;

TOP

5

1015

20

PUSH

5

20 15 10 5

20 15 10 5

ST

Page 27: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

27

Motivating ADTs

All built in types are ADTs

Use of ADTs:

Page 28: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

28

Motivating ADTs (contd..)

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

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

Page 29: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

29

ADT definition

Page 30: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

30

ADT examples

Set:

Multiset:

Sequence:

Graph:

Page 31: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

31

Abstract data types: Stack example

Stack ADT

module STACK_HANDLER 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

indicates that details of thedata structure are hidden to clients

Page 32: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

32

Abstract objects vs. ADTs

OK

OK

TH

IS

GO

I

S

O

D

Module objectSingle instanceHas state

Multiple instancesADT has no state Stack S1, S2, S3;

STACK ofchars

STACK

Page 33: Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:

33

Abstract data types: Summary

Proposed by B. Liskov (MIT) in 1975

Abstract data type:

ADTs and OO