1 software engineering: a practitioner’s approach, 6/e chapter 11a: component-level design...

14
1 Software Engineering: A Practitioner’s Approach, 6/e Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Chapter 11a: Component-Level Design Component-Level Design 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.

Upload: kathlyn-hodges

Post on 18-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design 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 11a:Chapter 11a:Component-Level DesignComponent-Level Design

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 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

2

What is a Component?What is a Component?

OMG Unified Modeling Language SpecificationOMG Unified Modeling Language Specification [OMG01] defines a component as [OMG01] defines a component as “… “… a modular, deployable, and replaceable part of a a modular, deployable, and replaceable part of a

system that encapsulates implementation and exposes a system that encapsulates implementation and exposes a set of interfaces.”set of interfaces.”

OO view: a component contains a set of OO view: a component contains a set of collaborating classescollaborating classes

Conventional view: logic, the internal data Conventional view: logic, the internal data structures that are required to implement the structures that are required to implement the processing logic, and an interface that enables processing logic, and an interface that enables the component to be invoked and data to be the component to be invoked and data to be passed to it.passed to it.

Page 3: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

3

OO ComponentOO Component

PrintJ ob

computeJ ob

init iateJ ob

numberOfPages numberOfSides paperType paperWeight

paperSize paperColor magnif ication colorRequirements productionFeatures

collat ionOptions bindingOptions coverStock bleed priority totalJ obCost

WOnumber

PrintJ ob

computePageCost () computePaperCost ()

computeProdCost () computeTotalJ obCost () buildWorkOrder() checkPriority () passJ obto Production()

elaborated design class<<interface>> computeJ ob

computePageCost ()

computePaperCost () computeProdCost () computeTotalJ obCost ()

<<interface>>

initiateJ ob

buildWorkOrder() checkPriority () passJ obto Production()

design component

numberOfPages

numberOfSides

paperType magnif ication

productionFeatures

PrintJ ob

computeJ obCost()

passJ obtoPrinter()

analysis c lass

Page 4: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

4

Conventional ComponentConventional Component

ComputePageCost

design component

accessCostsDB

getJ obData

elaborated module

PageCost

in: job size in: color=1, 2, 3, 4 in: pageSize = A, B, C, B out: BPC out: SF

in: numberPages in: numberDocs in: sides= 1, 2 in: color=1, 2, 3, 4 in: page size = A, B, C, B out: page cost

job size ( J S) =

numberPages * numberDocs;lookup base page cost (BPC) --> accessCostsDB (J S, color);

lookup size factor ( SF) --> accessCostDB ( J S, color, size)

job complexity factor ( J CF) = 1 + [(sides-1)* sideCost + SF]pagecost = BPC * J CF

getJ obData (numberPages, numberDocs, sides, color, pageSize, pageCost)

accessCostsDB (jobSize, color, pageSize, BPC, SF)computePageCost()

Page 5: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

5

Basic Design PrinciplesBasic Design Principles The Open-Closed Principle (OCP).The Open-Closed Principle (OCP). “A module [component] should be “A module [component] should be

open for extension but closed for modification.open for extension but closed for modification. The Liskov Substitution Principle (LSP).The Liskov Substitution Principle (LSP). “Subclasses should be “Subclasses should be

substitutable for their base classes.substitutable for their base classes. Dependency Inversion Principle (DIP).Dependency Inversion Principle (DIP). “Depend on abstractions. Do “Depend on abstractions. Do

not depend on concretions.”not depend on concretions.” The Interface Segregation Principle (ISP).The Interface Segregation Principle (ISP). “Many client-specific “Many client-specific

interfaces are better than one general purpose interface.interfaces are better than one general purpose interface. The Release Reuse Equivalency Principle (REP).The Release Reuse Equivalency Principle (REP). “The granule of reuse “The granule of reuse

is the granule of release.”is the granule of release.” The Common Closure Principle (CCP).The Common Closure Principle (CCP). “Classes that change together “Classes that change together

belong together.” belong together.” The Common Reuse Principle (CRP).The Common Reuse Principle (CRP). “Classes that aren’t reused “Classes that aren’t reused

together should not be grouped together.”together should not be grouped together.”

Source: Martin, R., “Design Principles and Design Patterns,” downloaded from Source: Martin, R., “Design Principles and Design Patterns,” downloaded from http:www.objectmentor.com, 2000.http:www.objectmentor.com, 2000.

Page 6: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

6

Design GuidelinesDesign Guidelines ComponentsComponents

Naming conventions should be established for components that are Naming conventions should be established for components that are specified as part of the architectural model and then refined and specified as part of the architectural model and then refined and elaborated as part of the component-level modelelaborated as part of the component-level model

InterfacesInterfaces Interfaces provide important information about communication and Interfaces provide important information about communication and

collaboration (as well as helping us to achieve the OPC)collaboration (as well as helping us to achieve the OPC) Dependencies and InheritanceDependencies and Inheritance

it is a good idea to model dependencies from left to right and it is a good idea to model dependencies from left to right and inheritance from bottom (derived classes) to top (base classes).inheritance from bottom (derived classes) to top (base classes).

Page 7: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

7

CohesionCohesion Conventional view: Conventional view:

the “single-mindedness” of a modulethe “single-mindedness” of a module OO view: OO view:

cohesioncohesion implies that a component or class implies that a component or class encapsulates only attributes and operations that are encapsulates only attributes and operations that are closely related to one another and to the class or closely related to one another and to the class or component itselfcomponent itself

Levels of cohesionLevels of cohesion FunctionalFunctional LayerLayer CommunicationalCommunicational SequentialSequential ProceduralProcedural TemporalTemporal utilityutility

Page 8: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

8

CouplingCoupling Conventional view: Conventional view:

The degree to which a component is connected to other The degree to which a component is connected to other components and to the external worldcomponents and to the external world

OO view:OO view: a qualitative measure of the degree to which classes a qualitative measure of the degree to which classes

are connected to one anotherare connected to one another Level of couplingLevel of coupling

ContentContent CommonCommon ControlControl StampStamp DataData Routine callRoutine call Type useType use Inclusion or importInclusion or import ExternalExternal

Page 9: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

9

Component Level Design-IComponent Level Design-I

Step 1. Identify all design classes that correspond Step 1. Identify all design classes that correspond to the problem domain. to the problem domain.

Step 2. Identify all design classes that correspond Step 2. Identify all design classes that correspond to the infrastructure domain.to the infrastructure domain.

Step 3. Elaborate all design classes that are not Step 3. Elaborate all design classes that are not acquired as reusable components.acquired as reusable components.

Step 3a. Specify message details when classes or Step 3a. Specify message details when classes or component collaborate. component collaborate.

Step 3b. Identify appropriate interfaces for each Step 3b. Identify appropriate interfaces for each component. component.

Page 10: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

10

Component-Level Design-IIComponent-Level Design-II Step 3c. Elaborate attributes and define data types Step 3c. Elaborate attributes and define data types

and data structures required to implement them. and data structures required to implement them. Step 3d.Step 3d. Describe processing flow within each Describe processing flow within each

operation in detail.operation in detail. Step 4. Describe persistent data sources (databases Step 4. Describe persistent data sources (databases

and files) and identify the classes required to and files) and identify the classes required to manage them. manage them.

Step 5. Develop and elaborate behavioral Step 5. Develop and elaborate behavioral representations for a class or component. representations for a class or component.

Step 6. Elaborate deployment diagrams to provide Step 6. Elaborate deployment diagrams to provide additional implementation detail. additional implementation detail.

Step 7. Factor every component-level design Step 7. Factor every component-level design representation and always consider alternatives.representation and always consider alternatives.

Page 11: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

11

Collaboration DiagramCollaboration Diagram

:ProductionJob

:WorkOrder

:JobQueue

1: buildJob (WOnumber)2: submitJob (WOnumber)

Page 12: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

12

RefactoringRefactoring

PrintJ ob

computeJ ob

initiateJ ob

ProductionJ ob

buildJ ob

submitJ ob

WorkOrder

appropriate attributes

buildWorkOrder ()getJ obDescriiption

J obQueue

appropriate attributes

checkPriority ()

<<interface>> initiateJ ob

passJ obToProduction()

Page 13: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

13

Activity DiagramActivity Diagram

validate attributes input

accessPaperDB(weight)

returns baseCostperPage

size = B paperCostperPage = paperCostperPage *1 .2

size = C paperCostperPage = paperCostperPage *1 .4

size = D paperCostperPage = paperCostperPage *1 .6

color is custompaperCostperPage = paperCostperPage *1 .1 4

color is standard

paperCostperPage = baseCostperPage

returns( paperCostperPage )

Page 14: 1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter

14

StatechartStatechart

buildingJ obData

entry/ readJ obData() exit/displayJ obData() do/ checkConsistency() include/ dataInput

entry/ computeJ ob exit/ save totalJ obCost

formingJ ob

entry/ buildJ ob exit/ save WOnumber do/

computingJ obCost

submittingJ ob

entry/ submitJ ob exit/initiateJ ob do/ place on J obQueue

behavior within the state buildingJ obData

dataInputCompleted [all data items consistent]/ displayUserOptions

dataInputIncomplete

jobCostAccepted [customer is authorized]/ getElectronicSignature

jobSubmitted [all authorizations acquired]/ printWorkOrder