meljun cortes software eng'g chapter5

35
1 Software Engineering: A Practitioner’s Approach, 6/e Software Engineering: A Practitioner’s Approach, 6/e Chapter 5 Chapter 5 Design Engineering Design Engineering MELJUN P. CORTES,MBA,MPA,BSCS MELJUN P. CORTES,MBA,MPA,BSCS

Upload: meljun-cortes

Post on 30-Jan-2015

381 views

Category:

Documents


5 download

DESCRIPTION

MELJUN CORTES Software Eng'g Chapter5

TRANSCRIPT

Page 1: MELJUN CORTES Software Eng'g Chapter5

1

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

Chapter 5Chapter 5Design EngineeringDesign Engineering

MELJUN P. CORTES,MBA,MPA,BSCSMELJUN P. CORTES,MBA,MPA,BSCS

Page 2: MELJUN CORTES Software Eng'g Chapter5

2

Design Design EngineeringEngineering

Creativity rules - coming together Creativity rules - coming together of customer requirements, business of customer requirements, business needs, technical considerationsneeds, technical considerations

Design Specs: representation of Design Specs: representation of S/W, with details about S/W data S/W, with details about S/W data structures, architecture, interfaces, structures, architecture, interfaces, components and deploymentcomponents and deployment

Page 3: MELJUN CORTES Software Eng'g Chapter5

3

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 4: MELJUN CORTES Software Eng'g Chapter5

4

Generic Task SetGeneric Task Set Design data structures, or data objects and their Design data structures, or data objects and their

attributes as appropriate to the information domain attributes as appropriate to the information domain modelmodel

Using the analysis model decide on the architectural Using the analysis model decide on the architectural style appropriate for the softwarestyle appropriate for the software

Partition the analysis model into design subsystems Partition the analysis model into design subsystems and allocate these subsystem within the architecture:and allocate these subsystem within the architecture: Ensure that each subsystem is functionally cohesiveEnsure that each subsystem is functionally cohesive Design subsystem interfacesDesign subsystem interfaces Allocate analysis classes or functions to each subsystemAllocate analysis classes or functions to each subsystem

Page 5: MELJUN CORTES Software Eng'g Chapter5

5

Generic Task SetGeneric Task Set

Create a set of design classes or components:Create a set of design classes or components: Translate each analysis class description into a design classTranslate each analysis class description into a design class Check each design class against quality criteriaCheck each design class against quality criteria Consider inheritance issuesConsider inheritance issues Define methods and messages for each design classDefine methods and messages for each design class Evaluate and select design patterns for each design class or Evaluate and select design patterns for each design class or

a subsystema subsystem Review the design classes and revise if neededReview the design classes and revise if needed

Design interfaces to external systems or devicesDesign interfaces to external systems or devices

Page 6: MELJUN CORTES Software Eng'g Chapter5

6

Generic Task SetGeneric Task Set Design the user interface:Design the user interface:

Review results of task analysisReview results of task analysis Specify action sequences based on user scenariosSpecify action sequences based on user scenarios Create the behavioral model of the interfaceCreate the behavioral model of the interface Define interface objects and control mechanismsDefine interface objects and control mechanisms Review the interface design and revise, if neededReview the interface design and revise, if needed

Conduct component-level design:Conduct component-level design: Specify all algorithms at a relatively low level of abstractionSpecify all algorithms at a relatively low level of abstraction Refine the interface of each componentRefine the interface of each component Define component-level data structuresDefine component-level data structures Review each component and correct any errors foundReview each component and correct any errors found

Develop a deployment modelDevelop a deployment model

Page 7: MELJUN CORTES Software Eng'g Chapter5

7

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, contained in the analysis model, and it must accommodate all of the implicit and 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 for those who generate code and for those who test and subsequently support the those who test and subsequently support the software.software.

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

Page 8: MELJUN CORTES Software Eng'g Chapter5

8

Quality GuidelinesQuality Guidelines A design should exhibit an architectureA design should exhibit an architecture that that

has been created using recognizable architectural styles or patterns,has been created using recognizable architectural styles or patterns,

is composed of components that exhibit good design characteristics andis composed of components that exhibit good design characteristics and can be implemented in an evolutionary fashioncan 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 ; that is, the software should be logically partitioned into elements or subsystemspartitioned into elements or subsystems

A design should contain distinct representationsA design should contain distinct representations of data, architecture, of data, architecture, interfaces, and components.interfaces, and components.

A design should lead to data structures that are appropriateA design should lead to data structures that are appropriate for the classes for the classes to be implemented and are drawn from recognizable data patterns.to be implemented and are drawn from recognizable data patterns.

A design should lead to components that exhibit independent functional A design should lead to components that exhibit independent functional characteristicscharacteristics..

A design should lead to interfaces that reduce the complexityA design should lead to interfaces that reduce the complexity of of connections between components and with the external environment.connections between 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 that is driven by information obtained during software requirements analysis.information obtained during software requirements analysis.

A design should be represented using a notation that effectively A design should be represented using a notation that effectively communicates its meaningcommunicates its meaning..

Page 9: MELJUN CORTES Software Eng'g Chapter5

9

Quality AttributesQuality Attributes Functionality Functionality - assessed by evaluating the feature set - assessed by evaluating the feature set

and capabilities of a program, generality of functions and capabilities of a program, generality of functions delivered, security of the overall systemdelivered, security of the overall system

Usability Usability - assessed by evaluating human factors - assessed by evaluating human factors (aesthetics, consistency, documentation)(aesthetics, consistency, documentation)

Reliability Reliability - evaluated by measuring MTBF and - evaluated by measuring MTBF and severity of failures, MTTR, ability to recover from severity of failures, MTTR, ability to recover from failure, predictabilityfailure, predictability

Performance Performance - evaluated by measuring processing - evaluated by measuring processing speed, response time, resource consumption, speed, response time, resource consumption, throughput, efficiency, etc.throughput, efficiency, etc.

Supportability Supportability - extensibility, adaptability, - extensibility, adaptability, serviceability, testability, compatibility, configurabilityserviceability, testability, compatibility, configurability

Page 10: MELJUN CORTES Software Eng'g Chapter5

10

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” The design should “minimize the intellectual distance”

[DAV95] between the software and the problem as it exists [DAV95] between the software and the problem as it exists in the real world. in the real 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 The design should be structured to degrade gently, even

when aberrant data, events, or operating conditions are when aberrant data, events, or operating conditions are encountered. 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 The design should be assessed for quality as it is being

created, not after the fact. created, 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 11: MELJUN CORTES Software Eng'g Chapter5

11

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 — conveys the essence” of a proven design

solutionsolution ModularityModularity — compartmentalization of data and — compartmentalization of data and

functionfunction HidingHiding — controlled interfaces— controlled interfaces Functional independenceFunctional independence — single-minded — single-minded

function and low couplingfunction and low coupling RefinementRefinement — elaboration of detail for all — elaboration of detail for all

abstractionsabstractions RefactoringRefactoring — a reorganization technique that — a reorganization technique that

simplifies the designsimplifies the design

Page 12: MELJUN CORTES Software Eng'g Chapter5

12

Data Data AbstractionAbstraction

doordoor

implemented as a data structure

manufacturermanufacturermodel numbermodel numbertypetypeswing directionswing directioninsertsinsertslightslights typetype numbernumberweightweightopening mechanismopening mechanism

Page 13: MELJUN CORTES Software Eng'g Chapter5

13

Procedural Procedural AbstractionAbstraction

openopen

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

details of enter details of enter algorithmalgorithm

Page 14: MELJUN CORTES Software Eng'g Chapter5

14

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 15: MELJUN CORTES Software Eng'g Chapter5

15

PatternsPatterns(i.e. named “nuggets” of (i.e. named “nuggets” of

insight…)insight…)Design Pattern TemplateDesign Pattern TemplatePattern name Pattern 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

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

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

Motivation Motivation — provides an example of the problem — provides an example of the problem

Applicability Applicability — notes specific design situations in which the pattern — notes specific design situations in which the pattern is applicableis applicable

Structure Structure — describes the classes that are required to implement — describes the classes that are required to implement the patternthe pattern

Participants Participants — 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

Collaborations Collaborations — describes how the participants collaborate to carry — describes how the participants collaborate to carry out their responsibilitiesout their responsibilities

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

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

Page 16: MELJUN CORTES Software Eng'g Chapter5

16

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

Page 17: MELJUN CORTES Software Eng'g Chapter5

17

Modularity: Modularity: Trade-offsTrade-offsWhat 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 18: MELJUN CORTES Software Eng'g Chapter5

18

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 19: MELJUN CORTES Software Eng'g Chapter5

19

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 20: MELJUN CORTES Software Eng'g Chapter5

20

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 21: MELJUN CORTES Software Eng'g Chapter5

21

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 22: MELJUN CORTES Software Eng'g Chapter5

22

Sizing Modules: Two Sizing Modules: Two ViewsViews

MODULE

What's inside??

How big is it??

Page 23: MELJUN CORTES Software Eng'g Chapter5

23

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 24: MELJUN CORTES Software Eng'g Chapter5

24

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 25: MELJUN CORTES Software Eng'g Chapter5

25

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 validation of data communicated between objects or

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

Page 26: MELJUN CORTES Software Eng'g Chapter5

26

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 27: MELJUN CORTES Software Eng'g Chapter5

27

MessageMessagess

:SenderObject

:ReceiverObject

message (<parameters>)

Page 28: MELJUN CORTES Software Eng'g Chapter5

28

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 …

Page 29: MELJUN CORTES Software Eng'g Chapter5

29

The Design ModelThe Design Model

process dimension

architecture elements

interface elements

component-level elements

deployment-level elements

low

high

class diagrams analysis packages CRC models collaboration diagrams

use-cases - text use-case diagrams activity diagrams swim lane diagrams collaboration diagrams data flow diagrams

control-flow diagrams processing narratives

data flow diagrams control-flow diagrams processing narratives

state diagrams sequence diagrams

state diagrams sequence diagrams

design class realizations subsystems collaboration diagrams

design class realizations subsystems collaboration diagrams

refinements to:

deployment diagrams

class diagrams analysis packages CRC models collaboration diagrams

component diagrams design classes activity diagrams sequence diagrams

refinements to:

component diagrams design classes activity diagrams sequence diagrams

design class realizations subsystems collaboration diagrams

component diagrams design classes activity diagrams sequence diagrams

analysis model

design model

Requirements: constraints interoperability targets and configuration

technical interface design Navigation design GUI design

Page 30: MELJUN CORTES Software Eng'g Chapter5

30

Design Model ElementsDesign Model Elements Data elementsData elements

Data model --> data structuresData model --> data structures Data model --> database architectureData model --> database architecture

Architectural elementsArchitectural elements Application domainApplication domain Analysis classes, their relationships, collaborations and Analysis classes, their relationships, collaborations and

behaviors are transformed into design realizationsbehaviors are transformed into design realizations Patterns and “styles” (Chapter 10)Patterns and “styles” (Chapter 10)

Interface elementsInterface elements the user interface (UI) the user interface (UI) external interfaces to other systems, devices, networks external interfaces to other systems, devices, networks

or other producers or consumers of informationor other producers or consumers of information internal interfaces between various design componentsinternal interfaces between various design components.

Component elementsComponent elements

Deployment elementsDeployment elements

Page 31: MELJUN CORTES Software Eng'g Chapter5

31

Interface ElementsInterface Elements

ControlPanel

LCDdisplay LEDindicators keyPadCharacteristics speaker wirelessInterface

readKeyStroke() decodeKey() displayStatus() lightLEDs() sendControlMsg()

Figure 9.6 UML interface representation for ControlPanel

KeyPad

readKeystroke() decodeKey()

<<interface>>

WirelessPDA

KeyPad

MobilePhone

Page 32: MELJUN CORTES Software Eng'g Chapter5

32

Component ElementsComponent Elements

SensorManagementSensor

Page 33: MELJUN CORTES Software Eng'g Chapter5

33

Deployment ElementsDeployment Elements

Figure 9.8 UML deployment diagram for SafeHome

Personal computer

Security

homeManagement

Surveillance

communication

Control Panel CPI server

Security homeownerAccess

externalAccess

Page 34: MELJUN CORTES Software Eng'g Chapter5

34

Design PatternsDesign Patterns The best designers in any field have an uncanny ability to The best designers in any field have an uncanny ability to

see patterns that characterize a problem and corresponding see patterns that characterize a problem and corresponding patterns that can be combined to create a solutionpatterns that can be combined to create a solution

A description of a design pattern may also consider a set of A description of a design pattern may also consider a set of design forces. design forces. Design forcesDesign forces describe non-functional requirements (e.g., ease describe non-functional requirements (e.g., ease

of maintainability, portability) associated the software for of maintainability, portability) associated the software for which the pattern is to be applied. which the pattern is to be applied.

The The pattern characteristicspattern characteristics (classes, responsibilities, and (classes, responsibilities, and collaborations) indicate the attributes of the design that collaborations) indicate the attributes of the design that may be adjusted to enable the pattern to accommodate a may be adjusted to enable the pattern to accommodate a variety of problems.variety of problems.

Page 35: MELJUN CORTES Software Eng'g Chapter5

35

FrameworksFrameworks

A A framework framework is not an architectural pattern, but is not an architectural pattern, but rather a skeleton with a collection of “plug rather a skeleton with a collection of “plug points” (also called points” (also called hookshooks and and slotsslots) that enable ) that enable it to be adapted to a specific problem domain. it to be adapted to a specific problem domain.

Gamma et al note that:Gamma et al note that: Design patterns are more abstract than frameworks.Design patterns are more abstract than frameworks. Design patterns are smaller architectural elements than Design patterns are smaller architectural elements than

frameworksframeworks Design patterns are less specialized than frameworksDesign patterns are less specialized than frameworks