1Chapter6RequirementsModeling:Scenarios,Information,andAnalysisClassesSoftwareEngineering:APractitioner’sApproach,7/ebyRogerS.Pressman2RequirementsAnalysisRequirementsanalysisspecifiessoftware’soperationalcharacteristicsindicatessoftware'sinterfacewithothersystemelementsestablishesconstraintsthatsoftwaremustmeetRequirementsanalysisallowsthesoftwareengineer(calledananalystormodelerinthisrole)to:elaborateonbasicrequirementsestablishedduringearlierrequirementengineeringtasksbuildmodelsthatdepictuserscenarios,functionalactivities,problemclassesandtheirrelationships,systemandclassbehavior,andtheflowofdataasitistransformed.3ABridgesystemdescriptionanalysismodeldesignmodel44TwoanalysismodelStructuredanalysis(SA)Object–orientedanalysis(OOA)功能(用例)模型对象/行为模型属性、协作操作、对象/关系模型5ElementsofRequirementsAnalysis6Scenario-BasedModeling“[Use-cases]aresimplyanaidtodefiningwhatexistsoutsidethesystem(actors)andwhatshouldbeperformedbythesystem(use-cases).”IvarJacobson(1)Whatshouldwewriteabout?(描述什么)(2)Howmuchshouldwewriteaboutit?(描述多少)(3)Howdetailedshouldwemakeourdescription?(描述多细)(4)Howshouldweorganizethedescription?(描述结构)7WhattoWriteAbout?Inceptionandelicitation—provideyouwiththeinformationyou’llneedtobeginwritingusecases.Requirementsgatheringmeetings,andotherrequirementsengineeringmechanismsareusedtodefinetheproblemscopespecifyoveralloperationalgoalsoutlineallknownfunctionalrequirementsdescribeobjectsthatwillbemanipulatedbysystemTobegindevelopingasetofusecases,listthefunctionsoractivitiesperformedbyaspecificactor.(考虑每一个角色是如何使用系统的)8HowMuchtoWriteAbout?Asfurtherconversationswiththestakeholdersprogress,therequirementsgatheringteamdevelopsusecasesforeachofthefunctions.usecasediagramascenariothatdescribesa“threadofusage”forasystemactorsrepresentrolespeopleordevicesplayasthesystemfunctionsuserscanplayanumberofdifferentrolesforagivenscenario9Use-CaseDiagramhomeownerAccesscamerasurveillanceviatheInternetConfigureSafeHomesystemparametersSetalarmcamerasSafeHomeascenariothatdescribesa“threadofusage”forasystemactorsrepresentrolespeopleordevicesplayasthesystemfunctionsuserscanplayanumberofdifferentrolesforagivenscenario10ActivityDiagramenterpasswordanduserIDselectmajorfunctionvalidpasswords/IDpromptforreentryinvalidpasswords/IDinputtriesremainnoinputtriesremainselectsurveillanceotherfunctionsmayalsobeselectedthumbnailviewsselectaspecificcameraselectcameraiconpromptforanotherviewselectspecificcamera-thumbnailsexitthisfunctionseeanothercameraviewcameraoutputinlabelledwindowSupplementstheusecasebyprovidingagraphicalrepresentationoftheflowofinteractionwithinaspecificscenario2019/8/1111ActivityDiagram活动图用于描述从活动到活动的流。它可用来为系统的动态方面建模,还可用来描述用例脚本。在活动图中,一个活动结束后立即进入下一个活动(在状态图中状态的变迁可能需要事件的触发)。控制流从一个动作或活动状态传递到下一个动作或活动状态称为跃迁,跃迁可以用简单的有向线条表示。分叉表示将单一的控制流分成两个或多个并发的控制流,分叉有一个输入和多个输出,分叉路径相关的活动是并行的。联结代表两个或多个并发控制流的同步,联结有多个输入和一个输出,在联结上,与各路径有关的活动是并行的。活动图描述发生了什么,但没有说明该活动由谁来完成。泳道决定各个活动由哪个类来完成。泳道用矩形框表示,属于某个泳道的活动放在该矩形框中,将对象名放在矩形框的顶部,表示泳道中的活动由谁负责。2019/8/1112ActivityDiagram:Example13SwimlaneDiagramsAllowsthemodelertorepresenttheflowofactivitiesdescribedbytheuse-caseandatthesametimeindicatewhichactororanalysisclasshasresponsibilityfortheactiondescribedbyanactivityrectangleenterpasswordanduserIDselectmajorfunctionvalidpasswords/IDpromptforreentryinvalidpasswords/IDinputtriesremainnoinputtriesremainselectsurveillanceotherfunctionsmayalsobeselectedthumbnailviewsselectaspecificcameraselectcameraicongeneratevideooutputselectspecificcamera-thumbnailsexitthisfunctionseeanothercamerahomeownercamerainterfacepromptforanotherviewviewcameraoutputinlabelledwindow14SwimlaneDiagrams泳道图2019/8/1115时序图时序图用于描述对象与对象之间动态的交互关系,着重体现对象间消息传递的时间顺序。时序图有两个轴水平轴表示不同的类/对象,垂直轴表示时间。时序图中的类/对象用一个带有垂直虚线的矩形框表示,并标有对象名/类名。垂直虚线是对象的生命线,用于表示在某段时间内对象是存在的。对象间的通信通过在对象的生命线间画消息来表示,消息从上到下,表明其发送的先后顺序。消息是对象间的一次通信,传达了要执行动作的信息,它能触发事件。消息可以是信号、操作、调用等,对象接收到消息时,立即开始执行指定活动,即对象被激活了。“激活”用对象生命线上的一个细长矩形框来表示。消息可以带序号(也可省略),还可带有条件表达式,表示该消息是否被发送。2019/8/1116时序图实例:如图描述了某公司管理系统的脚本“打印工资单”。首先,“PrintCilent”发送消息print(PayCheck,String)给PrintService,该对象发送消息给PayCheckPrinterImage以创建工资单,创建工资单的打印图象时,需要取得雇员的姓名,ID,工资数等,然后才建立打印图象,最后发送print(Image)消息给Printer,打印工资单的图象。激活生命线消息对象/类17DataModelingexaminesdataobjectsindependentlyofprocessingfocusesattentiononthedatadomaincreatesamodelatthecustomer’slevelofabstractionindicateshowdataobjectsrelatetooneanother18WhatisaDataObject?arepresentationofalmostanycompositeinformationthatmustbeunderstoodbysoftware.canbeanexternalentity(e.g.,anythingthatproducesorconsumesinformation),athing(e.g.,areportoradisplay),anoccurrence(e.g.,atelephonecall)orevent(e.g.,analarm),arole(e.g.,salesperson),anorganizationalunit(e.g.,accountingdepartment),aplace(e.g.,awarehouse),orastructure(e.g.,afile).Thedescriptionofdataobjectincludesthedataobjectandallofitsattributes.Adataobjectencapsulatesdataonly—thereisnoreferencewithinadataobjecttooperationsthatactonthedata.19DataObjectsandAttributesAdataobjectcontainsasetofattributesthatactasanaspect,quality,characteristic,ordescriptoroftheobjectobject: