外文翻译UML 20 序列图组合碎片.docx
《外文翻译UML 20 序列图组合碎片.docx》由会员分享,可在线阅读,更多相关《外文翻译UML 20 序列图组合碎片.docx(8页珍藏版)》请在冰豆网上搜索。
![外文翻译UML 20 序列图组合碎片.docx](https://file1.bdocx.com/fileroot1/2022-10/25/75873b4b-5714-4e94-ac3f-b5673cf28566/75873b4b-5714-4e94-ac3f-b5673cf285661.gif)
外文翻译UML20序列图组合碎片
中文2270字
UML2.0SequenceDiagramCombinedfragments
Thediagram'spurpose
Thesequencediagramisusedprimarilytoshowtheinteractionsbetweenobjectsinthesequentialorderthatthoseinteractionsoccur.Muchliketheclassdiagram,developerstypicallythinksequencediagramsweremeantexclusivelyforthem.However,anorganization'sbusinessstaffcanfindsequencediagramsusefultocommunicatehowthebusinesscurrentlyworksbyshowinghowvariousbusinessobjectsinteract.Besidesdocumentinganorganization'scurrentaffairs,abusiness-levelsequencediagramcanbeusedasarequirementsdocumenttocommunicaterequirementsforafuturesystemimplementation.Duringtherequirementsphaseofaproject,analystscantakeusecasestothenextlevelbyprovidingamoreformallevelofrefinement.Whenthatoccurs,usecasesareoftenrefinedintooneormoresequencediagrams.
Anorganization'stechnicalstaffcanfindsequencediagramsusefulindocumentinghowafuturesystemshouldbehave.Duringthedesignphase,architectsanddeveloperscanusethediagramtoforceoutthesystem'sobjectinteractions,thusfleshingoutoverallsystemdesign.
Oneoftheprimaryusesofsequencediagramsisinthetransitionfromrequirementsexpressedasusecasestothenextandmoreformallevelofrefinement.Usecasesareoftenrefinedintooneormoresequencediagrams.Inadditiontotheiruseindesigningnewsystems,sequencediagramscanbeusedtodocumenthowobjectsinanexisting(callit"legacy")systemcurrentlyinteract.Thisdocumentationisveryusefulwhentransitioningasystemtoanotherpersonororganization.
Thenotation
SincethisisthefirstarticleinmyUMLdiagramseriesthatisbasedonUML2,weneedtofirstdiscussanadditiontothenotationinUML2diagrams,namelyanotationelementcalledaframe.TheframeelementisusedasabasisformanyotherdiagramelementsinUML2,butthefirstplacemostpeoplewillencounteraframeelementisasthegraphicalboundaryofadiagram.Aframeelementprovidesaconsistentplaceforadiagram'slabel,whileprovidingagraphicalboundaryforthediagram.TheframeelementisoptionalinUMLdiagrams;asyoucanseeinFigures1and2,thediagram'slabelisplacedinthetopleftcornerinwhatI'llcalltheframe's"namebox,"asortofdog-earedrectangle,andtheactualUMLdiagramisdefinedwithinthebodyofthelargerenclosingrectangle.
Inmostsequencediagrams,however,theUML1.x"in-line"guardisnotsufficienttohandlethelogicrequiredforasequencebeingmodeled.ThislackoffunctionalitywasaprobleminUML1.x.UML2hasaddressedthisproblembyremovingthe"in-line"guardandaddinganotationelementcalledaCombinedFragment.Acombinedfragmentisusedtogroupsetsofmessagestogethertoshowconditionalflowinasequencediagram.TheUML2specificationidentifies11interactiontypesforcombinedfragments.
Alternatives
Alternativesareusedtodesignateamutuallyexclusivechoicebetweentwoormoremessagesequences.3Alternativesallowthemodelingoftheclassic"ifthenelse"logic(e.g.,ifIbuythreeitems,thenIget20%offmypurchase;elseIget10%offmypurchase).
AsyouwillnoticeinFigure8,analternativecombinationfragmentelementisdrawnusingaframe.Theword"alt"isplacedinsidetheframe'snamebox.ThelargerrectangleisthendividedintowhatUML2callsoperands.4Operandsareseparatedbyadashedline.Eachoperandisgivenaguardtotestagainst,andthisguardisplacedtowardsthetopleftsectionoftheoperandontopofalifeline.5Ifanoperand'sguardequatesto"true,"thenthatoperandistheoperandtofollow.
Figure8:
Asequencediagramfragmentthatcontainsanalternativecombinationfragment
Asanexampletoshowhowanalternativecombinationfragmentisread,Figure8showsthesequencestartingatthetop,withthebankobjectgettingthecheck'samountandtheaccount'sbalance.Atthispointinthesequencethealternativecombinationfragmenttakesover.Becauseoftheguard"[balance>=amount],"iftheaccount'sbalanceisgreaterthanorequaltotheamount,thenthesequencecontinueswiththebankobjectsendingtheaddDebitTransactionandstorePhotoOfCheckmessagestotheaccountobject.However,ifthebalanceisnotgreaterthanorequaltotheamount,thenthesequenceproceedswiththebankobjectsendingtheaddInsuffientFundFeeandnoteReturnedCheckmessagetotheaccountobjectandthereturnCheckmessagetoitself.Thesecondsequenceiscalledwhenthebalanceisnotgreaterthanorequaltotheamountbecauseofthe"[else]"guard.Inalternativecombinationfragments,the"[else]"guardisnotrequired;andifanoperanddoesnothaveanexplicitguardonit,thenthe"[else]"guardistobeassumed.
Alternativecombinationfragmentsarenotlimitedtosimple"ifthenels