软件工程实践者的研究方法课件_第1页
软件工程实践者的研究方法课件_第2页
软件工程实践者的研究方法课件_第3页
软件工程实践者的研究方法课件_第4页
软件工程实践者的研究方法课件_第5页
已阅读5页,还剩55页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1Chapter8DesignConceptsSoftwareEngineering:APractitioner’sApproach,7/e

byRogerS.Pressman1Chapter8DesignConceptsSoftw2DesignGoodsoftwaredesignshouldexhibit:Firmness(稳定性):Aprogramshouldnothaveanybugsthatinhibititsfunction.Commodity(适用性):Aprogramshouldbesuitableforthepurposesforwhichitwasintended.Delight(令人愉快):

Theexperienceofusingtheprogramshouldbepleasurableone.2DesignGoodsoftwaredesignsh3AnalysisModel=>DesignModel3AnalysisModel=>DesignMode43CharactersofDesignQualitythedesignmustimplementalloftheexplicit(明确的)requirementscontainedintheanalysismodel,anditmustaccommodatealloftheimplicit(隐含的)requirementsdesiredbythecustomer.thedesignmustbeareadable,understandableguideforthosewhogeneratecodeandforthosewhotestandsubsequentlysupportthesoftware.thedesignshouldprovideacompletepicture(全貌)ofthesoftware,addressingthedata,functional,andbehavioraldomainsfromanimplementationperspective.43CharactersofDesignQualit5QualityGuidelinesAdesignshouldexhibitanarchitecturethat(1)hasbeencreatedusingrecognizablearchitecturalstylesorpatterns,(2)iscomposedofcomponentsthatexhibitgooddesigncharacteristicsand(3)canbeimplementedinanevolutionaryfashionAdesignshouldbemodular;thatis,thesoftwareshouldbelogicallypartitionedintoelementsorsubsystemsAdesignshouldcontainrepresentationsofdata,architecture,interfaces,andcomponents.Adesignshouldleadtodatastructuresthatareappropriatefortheclassestobeimplemented.Adesignshouldleadtocomponentsthatexhibitindependentfunctionalcharacteristics.Adesignshouldleadtointerfacesthatreducethecomplexityofconnectionsbetweencomponentsandwiththeexternalenvironment.Adesignshouldbederivedusingarepeatablemethodthatisdrivenbyinformationobtainedduringsoftwarerequirementsanalysis.Adesignshouldberepresentedusinganotationthateffectivelycommunicatesitsmeaning.5QualityGuidelinesAdesignsh6DesignPrinciplesThedesignshouldbetraceabletotheanalysismodel.Thedesignshouldnotreinvent(彻底改造)thewheel.Thedesignshould“minimizethedistance”betweenthesoftwareandtheproblemasitexistsintherealworld.Thedesignshouldexhibituniformityandintegration.Thedesignshouldbestructuredtoaccommodatechange.Thedesignshouldbeassessedforqualityasitisbeingcreated,notafterthefact.Thedesignshouldbereviewedtominimizeconceptual(semantic)errors.Designisnotcoding,codingisnotdesign.FromDavis[DAV95]6DesignPrinciplesThedesigns7FundamentalConceptsAbstraction—data,procedureArchitecture(架构)—theoverallstructureofthesoftwarePatterns—conveys(承载)theessence(精髓)ofaprovendesignsolutionModularity—compartmentalization(划分)ofdataandfunctionInformationhiding—controlledinterfacesFunctionalindependence—single-mindedfunctionandlowcouplingAspects—amechanismforunderstandinghowglobalrequirementsaffectdesignRefactoring(重构)—areorganizationtechniquethatsimplifiesthedesignDesignClasses—providedesigndetailthatwillenableanalysisclassestobeimplemented7FundamentalConceptsAbstracti8DataAbstractiondoorimplementedasadatastructuremanufacturermodelnumbertypeswingdirectioninsertslightsweightopeningmechanism8DataAbstractiondoorimplement9ProceduralAbstractionopenimplementedwitha"knowledge"oftheobjectthatisassociatedwithenterdetailsofenteralgorithm9ProceduralAbstractionopenimp10Architecture“Theoverallstructureofthesoftwareandthewaysinwhichthatstructureprovidesconceptualintegrityforasystem.”Structuralproperties.

Thisaspectofthearchitecturaldesignrepresentationdefinesthecomponentsofasystem(e.g.,modules,objects)andthemannerinwhichthosecomponentsarepackagedandinteractwithoneanother.Forexample,objectsencapsulatebothdataandtheprocessingthatmanipulatesthedata.Extra-functionalproperties.Thearchitecturaldesigndescriptionshouldaddresshowthedesignarchitectureachievesrequirementsforperformance,capacity,reliability,security,adaptability,andothersystemcharacteristics.Families(族)ofrelatedsystems.Thearchitecturaldesignshoulddrawuponrepeatablepatternsthatarecommonlyencounteredinthedesignoffamiliesofsimilarsystems.Thedesignshouldhavetheabilitytoreusearchitecturalbuildingblocks.10Architecture“Theoverallstr11ArchitectureInthesimplestform,architectureisthestructureororganizationofprogramcomponents(modules),themannerinwhichthesecomponentsinteract,andthestructureofdatathatareusedbythecomponents.Inabroadersense,componentscanbegeneralizedtorepresentmajorsystemelementsandtheirinteractions.11ArchitectureInthesimplest12Modularity"modularityisthesingleattributeofsoftwarethatallowsaprogramtobeintellectuallymanageable".Monolithic(整块庞大的)software(i.e.,alargeprogramcomposedofasinglemodule)cannotbeeasilygrasped()byasoftwareengineer.Thenumberofcontrolpaths,spanofreference(引用跨度),numberofvariables,andoverallcomplexitywouldmakeunderstandingclosetoimpossible.Inalmostallinstances,youshouldbreakthedesignintomanymodules,hopingtomakeunderstandingeasierandasaconsequence,reducethecostrequiredtobuildthesoftware.12Modularity"modularityisthe13Modularity:numberofmodulesWhatisthe"right"numberofmodulesforaspecificsoftwaredesign?optimalnumberofmodulescostofsoftwarenumberofmodulesmoduleintegrationcostmoduledevelopmentcost13Modularity:numberofmodule14WhyInformationHiding?reducesthelikelihoodof“sideeffects”limitstheglobalimpactoflocaldesigndecisionsemphasizescommunicationthroughinterfacesdiscouragestheuseofglobaldataleadstoencapsulation—anattributeofhighqualitydesignresultsinhigherqualitysoftware14WhyInformationHiding?reduc15InformationHidingmoduleinterface"secret"•algorithm•datastructure•detailsofexternalinterface•resourceallocationpolicyclientsaspecificdesigndecision15InformationHidingmoduleinte16SizingModules:TwoViews16SizingModules:TwoViews17FunctionalIndependenceFunctionalindependenceisachievedbydevelopingmoduleswith"single-minded"functionandan"aversion"toexcessiveinteractionwithothermodules.Cohesion(内聚性)isanindicationoftherelativefunctionalstrengthofamodule.Acohesivemoduleperformsasingletask,requiringlittleinteractionwithothercomponentsinotherpartsofaprogram.Statedsimply,acohesivemoduleshould(ideally)dojustonething.Coupling(耦合性)isanindicationoftherelativeinterdependenceamongmodules.Couplingdependsontheinterfacecomplexitybetweenmodules,thepointatwhichentryorreferenceismadetoamodule,andwhatdatapassacrosstheinterface.17FunctionalIndependenceFunct18AspectAnaspectisarepresentationofacross-cuttingconcern.(横切关注点:利用“横切”技术,剖开封装的对象内部,将那些影响多个类的公共行为封装成一个可重用对象,称为Aspect)。ConsidertworequirementsAandB.BcrosscutsAifasoftwaredecompositionhasbeenchoseninwhichAcannotbesatisfiedwithouttakingB.AOP(AspectOrientedProgramming)是OOP的补充和完善。如:业务处理的主要流程是核心关注点,与之关系不大的部分是横切关注点,如权限认证、日志、事务处理等,可以将核心关注点和横切关注点分离开来。18AspectAnaspectisareprese19显示更新的需求:无论图元何时移动、移动到哪里,都要通知屏幕管理器(Display)其位置发生了改变。Aspect-Example19显示更新的需求:无论图元何时移动、移动到哪里,都要通知屏20采用OOP,典型做法是在每个移动图元的操作代码中,插入一段通知Display其位置发生改变的代码,即:调用Display.update()。ClassLine{privatePoint_p1,_p2;PointgetP1(){return_p1;}PointgetP2(){return_p2;}voidsetP1(Pointp1){ this._p1=p1;

Display.update();}voidsetP2(Pointp2){ this._p2=p2;

Display.update();}}ClassPoint{privateint_x1,_x2;intgetX(){return_x1;}intgetY(){return_x2;}voidsetX(intx1){ this._x1=x1;

Display.update();}voidsetY(intx2){ this._x2=x2;

Display.update();}}Aspect-Example20采用OOP,典型做法是在每个移动图元的操作代码中,21AspectDisplayUpdating{Pointcutmove():call(voidLine.setP1(Point))||call(voidLine.setP2(Point))||call(voidPoint.setX(int))||call(voidPoint.setY(int));after()returning:move(){

Display.update();}}ClassLine{

privatePoint_p1,_p2;

PointgetP1(){return_p1;}

PointgetP2(){return_p2;}

voidsetP1(Pointp1){

this._p1=p1;

}

voidsetP2(Pointp2){

this._p2=p2;

}

}

ClassPoint{

privateint_x1,_x2;

intgetX(){return_x1;}

intgetY(){return_x2;}

voidsetX(intx1){

this._x1=x1;

}

voidsetY(intx2){

this._x2=x2;

}

}

采用AOP,典型做法是在将所有移动图元的代码封装成一个Aspect:DisplayUpdating{}。Aspect-Example21AspectDisplayUpdating{Class22Aspect—AnExampleConsidertworequirementsfortheSafeHomeAWebApp.RequirementAisdescribedviatheuse-caseAccesscamerasurveillanceviatheInternet.

Adesignrefinementwouldfocusonthosemodulesthatwouldenablearegisteredusertoaccessvideofromcamerasplacedthroughoutaspace.RequirementBisagenericsecurityrequirementthatstatesthataregisteredusermustbevalidatedpriortousing

SafeHomeA.ThisrequirementisapplicableforallfunctionsthatareavailabletoregisteredSafeHomeusers.Asdesignrefinementoccurs,A*isadesignrepresentationforrequirementAandB*isadesignrepresentationforrequirementB.Therefore,A*andB*arerepresentationsofconcerns,andB*cross-cutsA*.Anaspectisarepresentationofacross-cuttingconcern.Therefore,thedesignrepresentation,B*,oftherequirement,aregisteredusermustbevalidatedpriortousing

SafeHomeA,isanaspectoftheSafeHomeWebApp.22Aspect—AnExampleConsidertw23RefactoringRefactoringistheprocessofchangingasoftwaresysteminsuchawaythatitdoesnotaltertheexternalbehaviorofthecode[design]yetimprovesitsinternalstructure.Whensoftwareisrefactored,theexistingdesignisexaminedforredundancyunuseddesignelementsinefficientorunnecessaryalgorithmspoorlyconstructedorinappropriatedatastructuresanyotherdesignfailurethatcanbecorrectedtoyieldabetterdesign.23RefactoringRefactoringisth24TheDesignModel24TheDesignModel25DesignModelElementsDataelementsDatamodel-->datastructuresDatamodel-->databasearchitectureArchitecturalelementsApplicationdomainAnalysisclasses,theirrelationships,collaborationsandbehaviorsaretransformedintodesignrealizationsInterfaceelementsComponentelementsDeploymentelements25DesignModelElementsDatael26ArchitecturalElementsThearchitecturalmodelisderivedfromthreesources:informationabouttheapplicationdomainforthesoftwaretobebuilt;specificrequirementsmodelelementssuchasdataflowdiagramsoranalysisclasses,theirrelationshipsandcollaborations.theavailabilityofarchitecturalpatterns.26ArchitecturalElementsThear27InterfaceElementsuserinterfaceexternalinterfacestoothersystems,devices.-includecheckinganddefinitiveinformationabouttheinformationissentorreceived(3)internalinterfacesbetweenvariousdesigncomponents.

-aninterfaceisasetofoperationsthatdescribessomepartofthebehaviorofaclassandprovidesaccesstotheseoperations.

27InterfaceElementsuserinter28InterfaceElements28InterfaceElements29ComponentElementscomponent-leveldesigndefinesdatastructuresforalllocaldataobjectsandalgorithmicdetailforallprocessingthatoccurswithinacomponentandaninterfacethatallowsaccesstoallcomponentoperations.29ComponentElementscomponent-30DeploymentElementsIndicatehowsoftwarefunctionalityandsubsystemswillbeallocatedwithinthephysicalcomputingenvironment30DeploymentElementsIndicate31Chapter8DesignConceptsSoftwareEngineering:APractitioner’sApproach,7/e

byRogerS.Pressman1Chapter8DesignConceptsSoftw32DesignGoodsoftwaredesignshouldexhibit:Firmness(稳定性):Aprogramshouldnothaveanybugsthatinhibititsfunction.Commodity(适用性):Aprogramshouldbesuitableforthepurposesforwhichitwasintended.Delight(令人愉快):

Theexperienceofusingtheprogramshouldbepleasurableone.2DesignGoodsoftwaredesignsh33AnalysisModel=>DesignModel3AnalysisModel=>DesignMode343CharactersofDesignQualitythedesignmustimplementalloftheexplicit(明确的)requirementscontainedintheanalysismodel,anditmustaccommodatealloftheimplicit(隐含的)requirementsdesiredbythecustomer.thedesignmustbeareadable,understandableguideforthosewhogeneratecodeandforthosewhotestandsubsequentlysupportthesoftware.thedesignshouldprovideacompletepicture(全貌)ofthesoftware,addressingthedata,functional,andbehavioraldomainsfromanimplementationperspective.43CharactersofDesignQualit35QualityGuidelinesAdesignshouldexhibitanarchitecturethat(1)hasbeencreatedusingrecognizablearchitecturalstylesorpatterns,(2)iscomposedofcomponentsthatexhibitgooddesigncharacteristicsand(3)canbeimplementedinanevolutionaryfashionAdesignshouldbemodular;thatis,thesoftwareshouldbelogicallypartitionedintoelementsorsubsystemsAdesignshouldcontainrepresentationsofdata,architecture,interfaces,andcomponents.Adesignshouldleadtodatastructuresthatareappropriatefortheclassestobeimplemented.Adesignshouldleadtocomponentsthatexhibitindependentfunctionalcharacteristics.Adesignshouldleadtointerfacesthatreducethecomplexityofconnectionsbetweencomponentsandwiththeexternalenvironment.Adesignshouldbederivedusingarepeatablemethodthatisdrivenbyinformationobtainedduringsoftwarerequirementsanalysis.Adesignshouldberepresentedusinganotationthateffectivelycommunicatesitsmeaning.5QualityGuidelinesAdesignsh36DesignPrinciplesThedesignshouldbetraceabletotheanalysismodel.Thedesignshouldnotreinvent(彻底改造)thewheel.Thedesignshould“minimizethedistance”betweenthesoftwareandtheproblemasitexistsintherealworld.Thedesignshouldexhibituniformityandintegration.Thedesignshouldbestructuredtoaccommodatechange.Thedesignshouldbeassessedforqualityasitisbeingcreated,notafterthefact.Thedesignshouldbereviewedtominimizeconceptual(semantic)errors.Designisnotcoding,codingisnotdesign.FromDavis[DAV95]6DesignPrinciplesThedesigns37FundamentalConceptsAbstraction—data,procedureArchitecture(架构)—theoverallstructureofthesoftwarePatterns—conveys(承载)theessence(精髓)ofaprovendesignsolutionModularity—compartmentalization(划分)ofdataandfunctionInformationhiding—controlledinterfacesFunctionalindependence—single-mindedfunctionandlowcouplingAspects—amechanismforunderstandinghowglobalrequirementsaffectdesignRefactoring(重构)—areorganizationtechniquethatsimplifiesthedesignDesignClasses—providedesigndetailthatwillenableanalysisclassestobeimplemented7FundamentalConceptsAbstracti38DataAbstractiondoorimplementedasadatastructuremanufacturermodelnumbertypeswingdirectioninsertslightsweightopeningmechanism8DataAbstractiondoorimplement39ProceduralAbstractionopenimplementedwitha"knowledge"oftheobjectthatisassociatedwithenterdetailsofenteralgorithm9ProceduralAbstractionopenimp40Architecture“Theoverallstructureofthesoftwareandthewaysinwhichthatstructureprovidesconceptualintegrityforasystem.”Structuralproperties.

Thisaspectofthearchitecturaldesignrepresentationdefinesthecomponentsofasystem(e.g.,modules,objects)andthemannerinwhichthosecomponentsarepackagedandinteractwithoneanother.Forexample,objectsencapsulatebothdataandtheprocessingthatmanipulatesthedata.Extra-functionalproperties.Thearchitecturaldesigndescriptionshouldaddresshowthedesignarchitectureachievesrequirementsforperformance,capacity,reliability,security,adaptability,andothersystemcharacteristics.Families(族)ofrelatedsystems.Thearchitecturaldesignshoulddrawuponrepeatablepatternsthatarecommonlyencounteredinthedesignoffamiliesofsimilarsystems.Thedesignshouldhavetheabilitytoreusearchitecturalbuildingblocks.10Architecture“Theoverallstr41ArchitectureInthesimplestform,architectureisthestructureororganizationofprogramcomponents(modules),themannerinwhichthesecomponentsinteract,andthestructureofdatathatareusedbythecomponents.Inabroadersense,componentscanbegeneralizedtorepresentmajorsystemelementsandtheirinteractions.11ArchitectureInthesimplest42Modularity"modularityisthesingleattributeofsoftwarethatallowsaprogramtobeintellectuallymanageable".Monolithic(整块庞大的)software(i.e.,alargeprogramcomposedofasinglemodule)cannotbeeasilygrasped()byasoftwareengineer.Thenumberofcontrolpaths,spanofreference(引用跨度),numberofvariables,andoverallcomplexitywouldmakeunderstandingclosetoimpossible.Inalmostallinstances,youshouldbreakthedesignintomanymodules,hopingtomakeunderstandingeasierandasaconsequence,reducethecostrequiredtobuildthesoftware.12Modularity"modularityisthe43Modularity:numberofmodulesWhatisthe"right"numberofmodulesforaspecificsoftwaredesign?optimalnumberofmodulescostofsoftwarenumberofmodulesmoduleintegrationcostmoduledevelopmentcost13Modularity:numberofmodule44WhyInformationHiding?reducesthelikelihoodof“sideeffects”limitstheglobalimpactoflocaldesigndecisionsemphasizescommunicationthroughinterfacesdiscouragestheuseofglobaldataleadstoencapsulation—anattributeofhighqualitydesignresultsinhigherqualitysoftware14WhyInformationHiding?reduc45InformationHidingmoduleinterface"secret"•algorithm•datastructure•detailsofexternalinterface•resourceallocationpolicyclientsaspecificdesigndecision15InformationHidingmoduleinte46SizingModules:TwoViews16SizingModules:TwoViews47FunctionalIndependenceFunctionalindependenceisachievedbydevelopingmoduleswith"single-minded"functionandan"aversion"toexcessiveinteractionwithothermodules.Cohesion(内聚性)isanindicationoftherelativefunctionalstrengthofamodule.Acohesivemoduleperformsasingletask,requiringlittleinteractionwithothercomponentsinotherpartsofaprogram.Statedsimply,acohesivemoduleshould(ideally)dojustonething.Coupling(耦合性)isanindicationoftherelativeinterdependenceamongmodules.Couplingdependsontheinterfacecomplexitybetweenmodules,thepointatwhichentryorreferenceismadetoamodule,andwhatdatapassacrosstheinterface.17FunctionalIndependenceFunct48AspectAnaspectisarepresentationofacross-cuttingconcern.(横切关注点:利用“横切”技术,剖开封装的对象内部,将那些影响多个类的公共行为封装成一个可重用对象,称为Aspect)。ConsidertworequirementsAandB.BcrosscutsAifasoftwaredecompositionhasbeenchoseninwhichAcannotbesatisfiedwithouttakingB.AOP(AspectOrientedProgramming)是OOP的补充和完善。如:业务处理的主要流程是核心关注点,与之关系不大的部分是横切关注点,如权限认证、日志、事务处理等,可以将核心关注点和横切关注点分离开来。18AspectAnaspectisareprese49显示更新的需求:无论图元何时移动、移动到哪里,都要通知屏幕管理器(Display)其位置发生了改变。Aspect-Example19显示更新的需求:无论图元何时移动、移动到哪里,都要通知屏50采用OOP,典型做法是在每个移动图元的操作代码中,插入一段通知Display其位置发生改变的代码,即:调用Display.update()。ClassLine{privatePoint_p1,_p2;PointgetP1(){return_p1;}PointgetP2(){return_p2;}voidsetP1(Pointp1){ this._p1=p1;

Display.update();}voidsetP2(Pointp2){ this._p2=p2;

Display.update();}}ClassPoint{privateint_x1,_x2;intgetX(){return_x1;}intgetY(){return_x2;}voidsetX(intx1){ this._x1=x1;

Display.update();}voidsetY(intx2){ this._x2=x2;

Display.update();}}Aspect-Example20采用OOP,典型做法是在每个移动图元的操作代码中,51AspectDisplayUpdating{Pointcutmove():call(voidLine.setP1(Point))||call(voidLine.setP2(Point))||call(voidPoint.setX(int))||call(voidPoint.setY(int));after()returning:move(){

Display.update();}}ClassLine{

privatePoint_p1,_p2;

PointgetP1(){return_p1;}

PointgetP2(){return_p2;}

voidsetP1(Pointp1){

this._p1=p1;

}

voidsetP2(Pointp2){

this._p2=p2;

}

}

ClassPoint{

privateint_x1,_x2;

intgetX(){return_x1;}

intgetY(){return_x2;}

voidsetX(intx1){

this._x1=x1;

}

voidsetY(intx2){

this._x2=x2;

}

}

采用AOP,典型做法是在将所有移动图元的代码封装成一个Aspect:DisplayUpdating{}。Aspect-Example21AspectDisplayUpdating{Class52Aspect—AnExampleConsidertworequirementsfortheSafeHomeAWebApp.RequirementAisdescribedviatheuse-caseAccesscamerasurveillanceviatheInternet.

Adesignrefinementwouldfocusonthosemodulesthatwouldenablearegisteredusertoaccessvideofromcamerasplacedthroughoutaspace.RequirementBisagenericsecurityrequirementthatstatesthataregisteredusermustbevalidatedpriortousing

SafeHomeA.ThisrequirementisapplicableforallfunctionsthatareavailabletoregisteredSafeHomeusers.Asdesignrefinementoccurs,A*isadesignrepresentationforrequirementAandB*isadesignrepresentationforrequirementB

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论