27
2004 by SEC Chapter 4 Software Design

2004 by SEC Chapter 4 Software Design. 2 2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

Embed Size (px)

Citation preview

Page 1: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

2004 by SEC

Chapter 4 Software Design

Page 2: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

2

2004 by SEC

Chapter 4 Software Design

4.1 Design Fundamentals

4.2 Design Method

4.3 Architecture Design

4.3.1 Architecture Patterns

4.4 Data Design

4.5 Interface Design

4.6 Procedural Design

Page 3: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

2004 by SEC

4.1 Design Fundamentals

Page 4: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

4

2004 by SEC

Design Fundamentals Design Step Procedures

Software Design vs. Requirement Analysis– Software design: requirements a representation of software

– requirement analysis: create a model to represent the requirements

functional requirement

information modelfunctional modelbehavioral model

data design data structure

architecturedesign

proceduredesign

relationship between structure components

depict structure componentie. a procedural description

of softwarenonfunctional requirement

•design constrain•performance•Cost•…

{

{

Page 5: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

5

2004 by SEC

Design Fundamentals (cont’d) Common Characteristics

– A mechanism for the translation of information domain representation into design representation

– A notation for representing functional components and their interfaces

– Heuristics for refinement and partitioning

Design Quality– Design is the place where quality is fostered in software engineering.

– Design provides us with representations of software that can be assessed for quality.

Page 6: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

6

2004 by SEC

Design Fundamentals (cont’d) Fundamental Concepts

– Abstraction

procedural abstraction

– a named sequence of instruction that has a specific function

data abstraction

– a named collection of data that describes a data object

– can refer to all the data by stating the name of the data abstraction

– original abstraction data type is used as a template or generic data structure from which the data structure can be instructed.

Level of abstractionHighest level

.Low level

.Lowest level

Language usedProblem-oriented terminology

.Procedural-oriented terminology

.Implementation-oriented terminology

Page 7: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

7

2004 by SEC

Design Fundamentals (cont’d)– Refinement

A top-down design strategy

A hierarchy is developed by decomposing a statement of function ( a procedural abstraction) in a stepwise fashion until programming statements are reached.

– Every refinement step implies some design decisions

A process of elaboration

– begins with a statement of function (or description of data) without the internal working of the function (or internal structure of the data).

– provides more and more details as each successive refinement occurs.

Page 8: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

8

2004 by SEC

Design Fundamentals (cont’d) Abstraction and refinement are complementary concepts.

Abstraction enables a designer to specify procedure and data, and even suppress low-level details.

Refinement on the other hand helps the designer revel low-level details as design progresses.

Both concepts aid the designer in creating a complete design model as the design evolves.

Page 9: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

9

2004 by SEC

Design Fundamentals (cont’d)

– Modularity

Modules: software is divided into separately named and addressable components, sometimes called modules.

Modules vs. Interfaces between modules

– Avoid overmodularity & undermodularity; notice the relationship between modules (the number of interfaces will increase exponentially with the number of modules.)

– trade-offs

Page 10: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

10

2004 by SEC

Design Fundamentals (cont’d)

optimal numberoptimal number of modulesof modules

cost ofcost of softwaresoftware

number of modulesnumber of modules

modulemoduleintegrationintegration

costcost

module development cost module development cost

• What is the right number of modules for a software design?

Page 11: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

11

2004 by SEC

Design Fundamentals (cont’d)

– Software architecture

It is the structure of program components, the manner in which these components interacts, and the structure of data used by the components.

It relates elements of a software solution to parts of a real-world problem.

Page 12: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

12

2004 by SEC

Design Fundamentals (cont’d)– Control hierarchy (program structure)

The organization of program components & implies a hierarchy of control

– Does not represent procedural aspects of software (iteration, condition, sequence)

Depth / width / fan-in / fan-out / superordinate / subordinate

Two characteristic of software architecture

– Visibility: program components may be invoked or used as data by given component (indirectly) (e.g. M4 is visible to M1)

– Connectivity: program components are directly invoked or used as data by given component (e.g. M2 is connected to M1)

A module that directly causes another module to begin execution is connected to it M1 M2

M3 M4

Page 13: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

13

2004 by SEC

Design Fundamentals (cont’d)– Software procedure focuses on the processing details of each module

individually (sequence, iteration, condition)

a procedural representation of software is layered

– Information hiding

Modules should be specified and designed so that information (procedure & data) contained within a module are inaccessible to other modules that have no need for such information.

Hiding implies that effective modularity design can be achieved by defining a set of independent modules.

Hiding defines access constraints to both procedural detail within a module and local data structure used by the module.

Provides the greatest benefits when program modification are required.

Page 14: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

2004 by SEC

4.2 Design Method

Page 15: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

15

2004 by SEC

Effective Modular Design Effective Modular Design

– A modular design reduces complexity, facilitates changes, results in an easier implementation.

– Classification (based on temporal aspect)

monolithicprogram

moduleprogram

object-orientedprogram

code-and-fix

sequential / incremental / parallel

subroutines / coroutines / conroutines

Without apparent interruption

/ Can be interrupted before completion

/ execute simultaneously with another module

Page 16: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

16

2004 by SEC

Effective Modular Design (cont’d)

– A typical control hierarchy may not be encountered when coroutines or conroutines are used

– Functional independence (independent effective modules) Effective modularity: function compartmentalized and interfaces

simplified

Page 17: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

17

2004 by SEC

Effective Modular Design (cont’d)– Cohesion: relative functional strength of a module

Types of Cohesion:

– coincidental : tasks relate to each other loosely inside a module

– logical : performing tasks related logically ( all output )

– temporal : all tasks executed with the same span of time

– procedural : must be executed in a specific order

– communicational : concentrate on one area of a data structure

– sequential

– functionalHigh

(good)

low

Page 18: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

18

2004 by SEC

Effective Modular Design (cont’d)– Coupling: interconnection among modules

depends on the interface complexity between modules, entry point or reference to a module, what data passes across the interface

Types of Coupling:– No direct coupling : module subordinate to different modules– Data coupling : data passed via argument list– Stamp coupling : data structure passed via argument list– control coupling : passes control data– external coupling : modules are tied to an external environment– common coupling : refer to a global data area– content coupling :

one module makes use of data or control information maintained within the boundary of another module .

branches are made into the middle of a modulehigh

(Good)low

Page 19: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

2004 by SEC

4.3 Architectural Design

Page 20: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

20

2004 by SEC

Architectural Design Program architecture, domain specific software

architecture– Develop a modular program structure

– Represent the control relationship between modules

Control hierarchy connecting modules

– Define interface that enable data to flow throughout the program

– System organization

– DSSA (Domain-Specific Software Architecture)

Pipes & filters

– I: a stream of inputs

– O: a stream of outputs

(1) program structure

(2) domain-specificSoftware

architecture

Page 21: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

21

2004 by SEC

Architecture Patterns Layered systems:

– System organized hierarchically with each layer providing service to the layer above it

Rule-based system

Blackboard systems: a central data structure represents the current state of the computation, a collection of knowledge sources.

System

Basic

Core

Knowledge Base

RB Fact

Rule & dataelement

Ruleinterpreter

WorkingMemoryInput

Output selectedrules/data

Blackboard

Page 22: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

22

2004 by SEC

4.4 Data Design– Define data abstractions

– Select an appropriate data structure to implement the abstraction

– Using entity-relationship modeling depict relationship between objects

data abstraction

data structure

data modeling

Page 23: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

2004 by SEC

4.5 Procedural Design

Page 24: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

24

2004 by SEC

Procedural Design Structure programming

– logical constructs: sequence, conditional, iteration

– to limit the procedural design to a small number of predictable operations

reduce program complexity lead to more readable, testable code

Flow charts– Graphical representation for procedural design

– Limitation

Introduce inefficiency when an escape from a set of nested loops or nested conditions is required

Additional complications of logical tests

Page 25: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

25

2004 by SEC

Procedural Design (cont’d) Program design language (PDL)

– Structured English (pseudocode) Uses the vocabulary of English Overall syntax of a structure programming language

– Difference between PDL and programming language The use of narrative text embedded directly within PDL statements PDL cannot be compiled but can be translated into a graphical

structure Why design language

– can be embedded with source code– can be a derivative of the high order language. e.g. Ada PDL– easy to review– can be represented in great detail

Page 26: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

26

2004 by SEC

PDL Data structure

– TYPE <var-name> IS <q-1> <q-2>

eg. TYPE table IS INSTANCE OF symboltable

Abstract data type: data abstraction– Generic data structure (template) from which other data structures can

be instantiated

– e.g. TYPE table IS INSTANCE OF symboltable

– Block structure

BEGIN

< ..... >

END

Page 27: 2004 by SEC Chapter 4 Software Design. 2  2004 by SEC Chapter 4 Software Design 4.1 Design Fundamentals 4.2 Design Method 4.3 Architecture Design 4.3.1

27

2004 by SEC

PDL (cont’d)– Conditional

-IF < >

THEN < >

ELSE < >

ENDIF

– Iteration-REPEAT UNTIL < >

< >

ENDREP

-DO WHILE < >

< >

ENDDO

-DO FOR < >

< >

ENDFOR

-CASE OF < >

WHEN < > SELECT < >

.

.

DEFAULT: < >

ENDCASE