23
1 Software Engineering: A Practitioner’s Approach, 6/e Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Chapter 9: 9.1-9.3 Design Engineering Design Engineering copyright © 1996, 2001, 2005 R.S. Pressman & Associates, Inc. For University Use Only May be reproduced ONLY for student use at the university level when used in conjunction with Software Engineering: A Practitioner's Approach. Any other reproduction or use is expressly prohibited.

1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

Embed Size (px)

Citation preview

Page 1: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

1

Software Engineering: A Practitioner’s Software Engineering: A Practitioner’s Approach, 6/eApproach, 6/e

Chapter 9: 9.1-9.3Chapter 9: 9.1-9.3Design EngineeringDesign Engineering

copyright © 1996, 2001, 2005

R.S. Pressman & Associates, Inc.

For University Use OnlyMay be reproduced ONLY for student use at the university level

when used in conjunction with Software Engineering: A Practitioner's Approach.Any other reproduction or use is expressly prohibited.

Page 2: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

2

Analysis Model -> Design Analysis Model -> Design ModelModel

Analysis Model

use-cases - text use-case diagrams activity diagrams swim lane diagrams

data flow diagrams control-flow diagrams processing narratives

f low-oriented elements

behavioralelements

class-basedelements

scenario-basedelements

class diagrams analysis packages CRC models collaboration diagrams

state diagrams sequence diagrams

Data/ Class Design

Architectural Design

Interface Design

Component- Level Design

Design Model

Page 3: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

3

Design and QualityDesign and Quality

the design must implement all of the explicit the design must implement all of the explicit requirementsrequirements contained in the analysis model, and contained in the analysis model, and it must accommodate all of the implicit it must accommodate all of the implicit requirements desired by the customer.requirements desired by the customer.

the design must be a readable, understandable the design must be a readable, understandable guideguide for those who generate code and for those for those who generate code and for those who test and subsequently support the software.who test and subsequently support the software.

the design should provide a complete picture of the design should provide a complete picture of the softwarethe software, addressing the data, functional, and , addressing the data, functional, and behavioral domains from an implementation behavioral domains from an implementation perspective.perspective.

Page 4: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

4

Quality GuidelinesQuality Guidelines A design should exhibit an architectureA design should exhibit an architecture that (1) has been created using recognizable that (1) has been created using recognizable

architectural styles or patterns, (2) is composed of components that exhibit good design architectural styles or patterns, (2) is composed of components that exhibit good design characteristics and (3) can be implemented in an evolutionary fashioncharacteristics and (3) can be implemented in an evolutionary fashion

For smaller systems, design can sometimes be developed linearly.For smaller systems, design can sometimes be developed linearly. A design should be modularA design should be modular; that is, the software should be logically partitioned into ; that is, the software should be logically partitioned into

elements or subsystemselements or subsystems A design should contain distinct representationsA design should contain distinct representations of data, architecture, interfaces, and of data, architecture, interfaces, and

components.components. A design should lead to data structures that are appropriateA design should lead to data structures that are appropriate for the classes to be for the classes to be

implemented and are drawn from recognizable data patterns.implemented and are drawn from recognizable data patterns. A design should lead to components that exhibit independent functional characteristicsA design should lead to components that exhibit independent functional characteristics.. A design should lead to interfaces that reduce the complexityA design should lead to interfaces that reduce the complexity of connections between of connections between

components and with the external environment.components and with the external environment. A design should be derived using a repeatable methodA design should be derived using a repeatable method that is driven by information that is driven by information

obtained during software requirements analysis.obtained during software requirements analysis. A design should be represented using a notation that effectively communicates its A design should be represented using a notation that effectively communicates its

meaningmeaning..

Page 5: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

5

Design Design PrinciplesPrinciples The design process should not suffer from ‘tunnel vision.’ The design process should not suffer from ‘tunnel vision.’

The design should be traceable to the analysis model. The design should be traceable to the analysis model. The design should not reinvent the wheel. The design should not reinvent the wheel. The design should “minimize the intellectual distance” [DAV95] The design should “minimize the intellectual distance” [DAV95]

between the software and the problem as it exists in the real between the software and the problem as it exists in the real world. world.

The design should exhibit uniformity and integration. The design should exhibit uniformity and integration. The design should be structured to accommodate change. The design should be structured to accommodate change. The design should be structured to degrade gently, even when The design should be structured to degrade gently, even when

aberrant data, events, or operating conditions are encountered. aberrant data, events, or operating conditions are encountered. Design is not coding, coding is not design. Design is not coding, coding is not design. The design should be assessed for quality as it is being created, The design should be assessed for quality as it is being created,

not after the fact. not after the fact. The design should be reviewed to minimize conceptual The design should be reviewed to minimize conceptual

(semantic) errors.(semantic) errors.From Davis [DAV95]

Page 6: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

6

Fundamental Fundamental ConceptsConcepts

abstractionabstraction—data, procedure, control—data, procedure, control architecturearchitecture—the overall structure of the software—the overall structure of the software patternspatterns—”conveys the essence” of a proven design solution—”conveys the essence” of a proven design solution modularitymodularity—compartmentalization of data and function—compartmentalization of data and function hidinghiding—controlled interfaces—controlled interfaces Functional independenceFunctional independence—single-minded function and low —single-minded function and low

couplingcoupling refinementrefinement—elaboration of detail for all abstractions—elaboration of detail for all abstractions RefactoringRefactoring—a reorganization technique that simplifies the —a reorganization technique that simplifies the

designdesign

Page 7: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

7

Data Data AbstractionAbstraction

doordoor

implemented as a data structure

manufacturermanufacturermodel numbermodel numbertypetypeswing directionswing directioninsertsinsertslightslights typetype numbernumberweightweightopening mechanismopening mechanism

Page 8: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

8

Procedural Procedural AbstractionAbstraction

openopen

implemented with a "knowledge" of the object that is associated with enter

details of enter details of enter algorithmalgorithm

Page 9: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

9

ArchitectureArchitecture““The overall structure of the software and the The overall structure of the software and the ways in which that structure provides ways in which that structure provides conceptual integrity for a system.” [SHA95a]conceptual integrity for a system.” [SHA95a]

Structural properties.Structural properties. This aspect of the architectural design This aspect of the architectural design representation defines the components of a system (e.g., modules, representation defines the components of a system (e.g., modules, objects, filters) and the manner in which those components are objects, filters) and the manner in which those components are packaged and interact with one another. For example, objects are packaged and interact with one another. For example, objects are packaged to encapsulate both data and the processing that packaged to encapsulate both data and the processing that manipulates the data and interact via the invocation of methods manipulates the data and interact via the invocation of methods Extra-functional properties.Extra-functional properties. The architectural design description The architectural design description should address how the design architecture achieves requirements should address how the design architecture achieves requirements for performance, capacity, reliability, security, adaptability, and for performance, capacity, reliability, security, adaptability, and other system characteristics.other system characteristics.Families of related systems.Families of related systems. The architectural design should draw The architectural design should draw upon repeatable patterns that are commonly encountered in the upon repeatable patterns that are commonly encountered in the design of families of similar systems. In essence, the design should design of families of similar systems. In essence, the design should

have the ability to reuse architectural building blocks.have the ability to reuse architectural building blocks.

Page 10: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

10

PatternsPatternsDesign Pattern TemplateDesign Pattern TemplatePattern namePattern name—describes the essence of the pattern in a short but —describes the essence of the pattern in a short but expressive name expressive name

IntentIntent—describes the pattern and what it does—describes the pattern and what it does

Also-known-asAlso-known-as—lists any synonyms for the pattern—lists any synonyms for the pattern

MotivationMotivation—provides an example of the problem —provides an example of the problem

ApplicabilityApplicability—notes specific design situations in which the pattern is —notes specific design situations in which the pattern is applicableapplicable

StructureStructure—describes the classes that are required to implement the —describes the classes that are required to implement the patternpattern

ParticipantsParticipants—describes the responsibilities of the classes that are —describes the responsibilities of the classes that are required to implement the patternrequired to implement the pattern

CollaborationsCollaborations—describes how the participants collaborate to carry out —describes how the participants collaborate to carry out their responsibilitiestheir responsibilities

ConsequencesConsequences—describes the “design forces” that affect the pattern and —describes the “design forces” that affect the pattern and the potential trade-offs that must be considered when the pattern is the potential trade-offs that must be considered when the pattern is implementedimplemented

Related patternsRelated patterns—cross-references related design patterns—cross-references related design patterns

Page 11: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

11

Modular Modular DesignDesigneasier to build, easier to change, easier to fix ...

Page 12: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

12

Modularity: Trade-Modularity: Trade-offsoffsWhat is the "right" number of modules What is the "right" number of modules

for a specific software design?for a specific software design?

optimal numberoptimal number of modulesof modules

cost ofcost of softwaresoftware

number of modulesnumber of modules

modulemoduleintegrationintegration

costcost

module development cost module development cost

Page 13: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

13

Information HidingInformation Hiding

modulemodulecontrolledcontrolledinterfaceinterface

"secret""secret"

• • algorithmalgorithm

• • data structuredata structure

• • details of external interfacedetails of external interface

• • resource allocation policyresource allocation policy

clientsclients

a specific design decisiona specific design decision

Page 14: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

14

Why Information Why Information Hiding?Hiding?

reduces the likelihood of “side reduces the likelihood of “side effects”effects”

limits the global impact of local limits the global impact of local design decisionsdesign decisions

emphasizes communication through emphasizes communication through controlled interfacescontrolled interfaces

discourages the use of global datadiscourages the use of global data leads to encapsulation—an attribute leads to encapsulation—an attribute

of high quality designof high quality design results in higher quality softwareresults in higher quality software

Page 15: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

15

Stepwise Stepwise RefinementRefinementopen

walk to door;reach for knob;

open door;

walk through;close door.

repeat until door opensturn knob clockwise;if knob doesn't turn, then take key out; find correct key; insert in lock;endifpull/push doormove out of way;end repeat

Page 16: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

16

Functional Functional IndependenceIndependence

COHESION - the degree to which a module performs one and only one function. COUPLING - the degree to which a module is "connected" to other modules in the system.

Page 17: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

17

Sizing Modules: Two Sizing Modules: Two ViewsViews

MODULE

What's inside??

How big is it??

Page 18: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

18

RefactoringRefactoring Fowler [FOW99] defines refactoring in the following

manner: "Refactoring is the process of changing a software

system in such a way that it does not alter the external behavior of the code [design] yet improves its internal structure.”

When software is refactored, the existing design is examined for redundancy unused design elements inefficient or unnecessary algorithms poorly constructed or inappropriate data structures or any other design failure that can be corrected to

yield a better design.

Page 19: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

19

OO Design ConceptsOO Design Concepts Design classesDesign classes

Entity classesEntity classes Boundary classesBoundary classes Controller classesController classes

InheritanceInheritance—all responsibilities of a superclass is —all responsibilities of a superclass is immediately inherited by all subclassesimmediately inherited by all subclasses

MessagesMessages—stimulate some behavior to occur in the —stimulate some behavior to occur in the receiving objectreceiving object

PolymorphismPolymorphism—a characteristic that greatly reduces —a characteristic that greatly reduces the effort required to extend the designthe effort required to extend the design

Page 20: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

20

Design ClassesDesign Classes Analysis classes are refined during design to become Analysis classes are refined during design to become

entity classesentity classes Boundary classesBoundary classes are developed during design to create are developed during design to create

the interface (e.g., interactive screen or printed reports) the interface (e.g., interactive screen or printed reports) that the user sees and interacts with as the software is that the user sees and interacts with as the software is used. used.

Boundary classes are designed with the responsibility of Boundary classes are designed with the responsibility of managing the way entity objects are represented to users. managing the way entity objects are represented to users.

Controller classeController classess are designed to manage are designed to manage the creation or update of entity objects; the creation or update of entity objects; the instantiation of boundary objects as they obtain the instantiation of boundary objects as they obtain

information from entity objects; information from entity objects; complex communication between sets of objects; complex communication between sets of objects; validation of data communicated between objects or between validation of data communicated between objects or between

the user and the application.the user and the application.

Page 21: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

21

InheritanceInheritance

Design options:Design options: The class can be designed and built from scratch. That is, The class can be designed and built from scratch. That is,

inheritance is not used.inheritance is not used. The class hierarchy can be searched to determine if a The class hierarchy can be searched to determine if a

class higher in the hierarchy (a superclass)contains most class higher in the hierarchy (a superclass)contains most of the required attributes and operations. The new class of the required attributes and operations. The new class inherits from the superclass and additions may then be inherits from the superclass and additions may then be added, as required.added, as required.

The class hierarchy can be restructured so that the The class hierarchy can be restructured so that the required attributes and operations can be inherited by required attributes and operations can be inherited by the new class.the new class.

Characteristics of an existing class can be overridden and Characteristics of an existing class can be overridden and different versions of attributes or operations are different versions of attributes or operations are implemented for the new class.implemented for the new class.

Page 22: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

22

MessageMessagess

:SenderObject

:ReceiverObject

message (<parameters>)

Page 23: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 9: 9.1-9.3 Design Engineering Software Engineering: A Practitioner’s Approach, 6/e Chapter

23

PolymorphismPolymorphism

case of graphtype:case of graphtype:

if graphtype = linegraph then DrawLineGraph (data);if graphtype = linegraph then DrawLineGraph (data);

if graphtype = piechart then DrawPieChart (data);if graphtype = piechart then DrawPieChart (data);

if graphtype = histogram then DrawHisto (data);if graphtype = histogram then DrawHisto (data);

if graphtype = kiviat then DrawKiviat (data);if graphtype = kiviat then DrawKiviat (data);

end case;end case;

All of the graphs become subclasses of a general class All of the graphs become subclasses of a general class called graph. Using a concept called overloading [TAY90], called graph. Using a concept called overloading [TAY90], each subclass defines an operation called each subclass defines an operation called drawdraw. An object . An object can send a can send a drawdraw message to any one of the objects message to any one of the objects instantiated from any one of the subclasses. The object instantiated from any one of the subclasses. The object receiving the message will invoke its own receiving the message will invoke its own drawdraw operation operation to create the appropriate graph. to create the appropriate graph.

graphtype drawgraphtype draw

ConventionalConventional approach …approach …