Sie sind auf Seite 1von 10

Chapter Comments

11-1

Chapter

11

ComponentLevelDesign
CHAPTEROVERVIEWANDCOMMENTS Thischapterdiscussestheportionofthesoftwaredevelopmentprocesswhere thedesigniselaboratedandtheindividualdataelementsandoperationsare designedindetail.First,differentviewsofacomponentareintroduced. Guidelinesforthedesignofobjectorientedandtraditional(conventional) programcomponentsarepresented. 11.1 WhatisaComponent? Thissectiondefinesthetermcomponentanddiscussesthedifferencesbetween objectoriented,traditional,andprocessrelatedviewsofcomponentleveldesign. ObjectManagementGroupOMGUMLdefinesacomponentasamodular, deployable,andreplaceablepartofasystemthatencapsulatesimplementation andexposesasetofinterfaces. 11.1.1AnObjectOrientedView OOview:acomponentcontainsasetofcollaboratingclasses. Eachclasswithinacomponenthasbeenfullyelaboratedtoincludeallattributes andoperationsthatarerelevanttoitsimplementation.Aspartofthedesign elaboration,allinterfaces(messages)thatenabletheclassestocommunicateand collaboratewithotherdesignclassesmustalsobedefined.Toaccomplishthis, thedesignerbeginswiththeanalysismodelandelaboratesanalysisclasses(for componentsthatrelatetotheproblemdomain)andinfrastructureclasses(or componentsthatprovidesupportservicesfortheproblemdomain). FigurebelowshowsExampleofElaborationofadesigncomponent.

11-2

SEPA, 6/e Instructors Guide

analysis c lass Print J ob numberOf Pages numberOf Sides paperType magnif ic at ion produc tionFeat ures design c omponent c omputeJ obCost( ) passJ obt oPrint er( ) c omput eJ ob

Print J ob

initiat eJ ob

<<in terf ace>> co mp u teJ o b com putePageCost ( ) com putePaperCost ( ) com puteProdCost () com puteTot alJ obCost ( )

elaborated design class PrintJ ob


num berOf Pages num berOf Sides paperType paperWeight paperSize paperColor m agnif ication colorR equirem ents product ionFeat ures collationOptions bindingOpt ions coverSt ock bleed priorit y t otalJ obCost WOnum ber com putePageCost ( ) com putePaperCost () com puteProdCost ( ) com puteTot alJ obCost ( ) buildWorkOrder( ) checkPriorit y ( ) passJ obto Production()

<<in terf ace>> in it iat eJ o b buildWorkOrder( ) checkPriorit y () passJ obt o Product ion( )

Chapter Comments

11-3

11.1.2TheConventionalView Conventionalview:acomponentisafunctionalelementofaprogramthat incorporatesprocessinglogic,theinternaldatastructuresthatarerequiredto implementtheprocessinglogic,andaninterfacethatenablesthecomponentto beinvokedanddatatobepassedtoit. Aconventionalcomponent,alsocalledamodule,resideswithinthes/w architectureandservesoneofthreeimportantrolesas: 1. Acontrolcomponentthatcoordinatestheinvocationofallotherproblem domaincomponents, 2. Aproblemdomaincomponentthatimplementsacompleteorpartialfunction thatisrequiredbythecustomer, 3. Aninfrastructurecomponentthatisresponsibleforfunctionsthatsupportthe processingrequiredintheproblemdomain. Exampleofastructurechartforaconventionalsystem:

11-4

SEPA, 6/e Instructors Guide

design component getJ obData ComputePageCost

accessCostsDB

elaborated module PageCost


in: numberPages in: numberDocs in: sides= 1, 2 in: color= 1, 2, 3, 4 in: page size = A, B, C, B out : page cost in: job size in: color= 1, 2, 3, 4 in: pageSize = A, B, C, B out : BPC out : SF get J obDat a ( numberPages, numberDocs, sides, color, pageSize, pageCost ) accessCost sDB (jobSize, color, pageSize, BPC, SF ) comput ePageCost ) (

job size ( J S) = numberPages * numberDocs; lookup base page cost ( BP C) --> accessCost sDB ( J S, color) ; lookup size fact or ( SF) --> accessCost DB ( J S, color, size) job complexit y fact or ( J CF) = 1 + [ ( sides-1) * sideCost + SF] pagecost = BPC * J CF

Chapter Comments

11-5

11.2DesigningClassBasedComponents TheseprinciplescanbeusedtoguidethedesigneraseachS/Wcomponentis developed. TheOpenClosedPrinciple(OCP).Amodule[component]shouldbeopenfor extensionbutclosedformodification.Thedesignershouldspecifythe componentinawaythatallowsittobeextendedwithouttheneedtomake internal(codeorlogiclevel)modificationstothecomponent. TheLiskovSubstitutionPrinciple(LSP).Subclassesshouldbesubstitutable fortheirbaseclasses.Acomponentthatusesabaseclassshouldcontinueto functionproperlyifaclassderivedfromthebaseclassispassedtothe componentinstead. DependencyInversionPrinciple(DIP).Dependonabstractions.Donot dependonconcretions.Abstractionsaretheplacewhereadesigncanbe extendedwithoutgreatcomplications. TheInterfaceSegregationPrinciple(ISP).Manyclientspecificinterfacesare betterthanonegeneralpurposeinterface.Thedesignershouldcreatea specializedinterfacetoserveeachmajorcategoryofclients. TheReleaseReuseEquivalencyPrinciple(REP).Thegranuleofreuseisthe granuleofrelease.Whenclassesorcomponentsaredesignedforreuse,there isanimplicitcontractthatisestablishedbetweenthedeveloperofthe reusableentityandthepeoplewhowilluseit. TheCommonClosurePrinciple(CCP).Classesthatchangetogetherbelong together.Classesshouldbepackagedcohesively.Whensomecharacteristic ofanareamustchange,itislikelythatonlythoseclasseswithinthepackage willrequiremodification. TheCommonReusePrinciple(CRP).Classesthatarentreusedtogether shouldnotbegroupedtogether.Whenoneormoreclasseswithapackage changes,thereleasenumberofthepackagechanges. 11.2.2ComponentLevelDesignGuidelines Components Namingconventionsshouldbeestablishedforcomponentsthatare specifiedaspartofthearchitecturalmodelandthenrefinedand elaboratedaspartofthecomponentlevelmodel Interfaces

11-6

SEPA, 6/e Instructors Guide

Interfacesprovideimportantinformationaboutcommunication andcollaboration(aswellashelpingustoachievetheOCP) DependenciesandInheritance Itisagoodideatomodeldependenciesfromlefttorightand inheritancefrombottom(derivedclasses)totop(baseclasses). 11.2.3Cohesion Cohesionimpliesthatacomponentorclassencapsulatesonlyattributesand operationsthatarecloselyrelatedtooneanotherandtotheclassorcomponent itself. Levelsofcohesion Functional:occurswhenamoduleperformsoneandonlyone computationandthenreturnsaresult. Layer:occurswhenahigherlayeraccessestheservicesofalower layer,butlowerlayersdonotaccesshigherlayers. Communicational:Alloperationsthataccessthesamedataaredefined withinoneclass. Sequential:Componentsoroperationsaregroupedinamannerthat allowsthefirsttoprovideinputtothenextandsoon. Procedural:Componentsoroperationsaregroupedinamannerthat allowsonetobeinvokedimmediatelyaftertheprecedingonewas invoked. Temporal:Operationsthatareperformedtoreflectaspecificbehavior orstate. Utility:Components,classes,oroperationsthatexistwithinthesame categorybutareotherwiseunrelatedaregroupedtogether. 11.2.4Coupling Conventionalview: Thedegreetowhichacomponentisconnectedtoothercomponents andtotheexternalworld OOview: aqualitativemeasureofthedegreetowhichclassesareconnectedto oneanother.Keepcouplingaslowaspossible. Levelofcoupling

Chapter Comments

11-7

Content:Occurswhenonecomponentsuperstitiouslymodifiesdata thatisinternaltoanothercomponent.ViolatesInformationhiding Common:Occurswhenanumberofcomponentsallmakeuseofa globalvariable. Control:OccurswhenoperationA()invokesoperationB()andpassesa controlflagtoB.ThecontrolflagthendirectslogicalflowwithinB. Stamp:OccurswhenClassBisdeclaredasatypeforanargumentof anoperationofClassA.BecauseClassBisnowapartofthedefinition ofClassA,modifyingthesystembecomesmorecomplex. Data:Occurswhenoperationspasslongstringsofdataarguments. Testingandmaintenancebecomesmoredifficult. Routinecall:Occurswhenoneoperationinvokesanother. Typeuse:OccurswhencomponentAusesadatatypedefinedin componentB. Inclusionorimport:OccurswhencomponentAimportsorincludesa packageorthecontentofcomponentB. External:Occurswhenacomponentcommunicatesorcollaborates withinfrastructurecomponents(O/Sfunction). 11.3ConductingComponentLevelDesign Thestepsdiscussedinthissectionprovideareasonabletasksetfordesigninga component.Youshouldemphasizethat(1)designclassesintheproblemdomain areusuallycustomdesigned,however,ifanorganizationhasencourageddesign forreuse,theremaybeanexistingcomponentthatfitsthebill;(2)designclasses correspondingtotheinfrastructuredomaincansometimesbeoftenfromexisting classlibraries;(3)aUMLcollaborationdiagramprovidesanindicationof messagepassingbetweencomponents. Step1.Identifyalldesignclassesthatcorrespondtotheproblemdomain. Step2.Identifyalldesignclassesthatcorrespondtotheinfrastructure domain. Step3.Elaboratealldesignclassesthatarenotacquiredasreusable components. Step3a.Specifymessagedetailswhenclassesorcomponentcollaborate. Step3b.Identifyappropriateinterfacesforeachcomponent.

11-8

SEPA, 6/e Instructors Guide

Step3c.Elaborateattributesanddefinedatatypesanddatastructures requiredtoimplementthem. Step3d.Describeprocessingflowwithineachoperationindetail. Step4.Describepersistentdatasources(databasesandfiles)andidentify theclassesrequiredtomanagethem. Step5.Developandelaboratebehavioralrepresentationsforaclassor component. Step6.Elaboratedeploymentdiagramstoprovideadditional implementationdetail. Step7.Factoreverycomponentleveldesignrepresentationandalways consideralternatives.

:P o u t n b r d c io Jo

1 b ild b : u Jo

( W n me Ou b r

2 s b it b : u m Jo

( W n me Ou b r

:W r Od r ok r e :Jo Q e e b uu

computeJ ob PrintJ ob initiateJ ob

WorkOrder
appropriate attributes

getJ obDescriiption

buildWorkOrder ()

buildJ ob ProductionJ ob submitJ ob

< <interface>> initiateJ ob


passJ obToProduction()

J obQueue
appropriate attributes

checkPriority ()

Chapter Comments

11-9

validate attributes input

acces sPaperDB (weight)

returns baseC ostperPage paperC ostperPage = baseC ostperPage

size = B

paperC ostperPage = paperC ostperPage * 1 .2

size = C

paperC ostperPage = paperC ostperPage * 1 .4

size = D

paperC ostperPage = paperC ostperPage * 1 .6

color is custom

paperC ostperPage = paperC ostperPage * 1 .1 4

color is standard

returns ( paperC ostperPage )

11-10

SEPA, 6/e Instructors Guide

behavior wit hin t he st at e buildingJ obDat a dat aInput Incomplet e

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

dat aInput Complet ed [ all dat a it ems consist ent ] / displayUserOpt ions

computingJ obCost entry/ computeJ ob exit/ save totalJ obCost

jobCost Accept ed [ cust omer is aut horized] / get Elect ronicSignat ure

formingJ ob entry/ buildJ ob exit/ save WOnumber do/

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

jobSubmit t ed[all aut horizat ions acquired] / print WorkOrder

Das könnte Ihnen auch gefallen