




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、第十四章.面向对象建模南京大学软件学院主要内容面向对象分析用例模型(行为模型)业务流程建模:活动图(行为模型)用例实现(交互):顺序图(行为模型)行为建模:状态图对象模型对象约束语言OCL面向对象建模1. 面向对象分析现实世界的复杂模型复杂总是简单部分的组合简单部分又是更简单部分的组合简单组成复杂的过程存在层次性每个最小简单部分独立负责完成一系列相关任务相比较而言,每个组合内部各部分的关系比其内部与外部的关系都更紧密各个部分通过一致的接口进行组合,即一个部分对其它部分的所知仅仅是接口1. 面向对象分析映射现实模型的面向对象思想任何系统都是能够完成一系列相关目标和任务的对象对象完成一个任务时会请
2、求一系列其他对象帮助其完成一些子目标其他对象为了完成其任务又会请求将子目标更细分为子子目标,并请求其他对象帮助完成子目标的分解和责任分担一直进行直到最后产生的子部分可以映射到计算实体计算实体:对象层次关系:聚合(组合)、继承、关联组合接口:一个对象暴露的接口1. 面向对象分析面向对象建模面向对象建模:一种用于辨识系统环境中的对象及这些对象之间关系的技术OMT (James Rumbaugh)Booch方法(Grady Booch) UMLOOSE (Ivar Jacobson)Coad-YourdonShlaer-MellorFusionJacobsonBoochJacobsonRumbaug
3、h1. 面向对象分析UML1. 面向对象分析UMLUML对象模型Object Model (Domain Model)用例模型Use Case Model行为模型Behavior Model状态机模型对象约束语言OCL主要内容面向对象分析用例模型(ch6.5)(行为模型)业务流程建模:活动图(ch5)(行为模型)用例实现(交互):顺序图(行为模型)行为建模:状态图对象模型对象约束语言OCL面向对象建模2. 用例模型用例模型就是以用例为基本单位建立的一个系统功能展示模型,它是系统所有用例的集合,以统一、图形化方式展示系统的功能和行为特性 用例是获取和组织用户需求的手段基本元素用例(Use Cas
4、e)参与者(Actor)关系(Relationship)系统边界(System Boundary) 2. 用例模型SpecialActorSpecialActorActorBase Use CaseExtending UseCaseSpecialized Use CaseGeneral UseCaseBase Use CaseIncluded UseCaseCommunication2. 用例模型Role of Use Case Diagrams主要内容面向对象分析用例模型(行为模型)业务流程建模:活动图(行为模型)用例实现(交互):顺序图(行为模型)行为建模:状态图对象模型对象约束语言OCL
5、面向对象建模Business process diagramA new form of data flow diagramAppears with business process reengineeringFour types of elements:Flow objectsConnecting objectsSwimlanesArtifactsBusiness process diagramActivity diagramsIntended for applications that need control flow or object/data flow models For exam
6、ple: business process modeling and workflow.It contents cover many use-cases and many classesIts adopted from BPMActivity Diagrams: the notationActionClass nameAction/activity node: an action or an activityObject node: represent an objectInitial node: beginning of a sequence of actions/activitiesFin
7、al activity node: stop all control flows and object flows in an activityFinal flow node: stop a specific control flow or object flowDecision nodeMerge nodeJoin nodeFork nodeSwim lane: break up an activity diagram into parts to assign the activities or actions to the actorsControl flowObject flow活动图示
8、例19Activity nodesThree type of activity nodes:Action nodes: executable activity nodes; the execution of an action represents some transformations or processes in the modeled system (already seen)Control nodes: coordinate flows in an activity diagram between other nodesObject nodes: indicate an insta
9、nce of a particular object, may be available at a particular point in the activity (i.e Pins are object nodes)Activity edges (1)Are directed connectionsThey have a source and a target, along which tokens may flowAny number of tokens can pass along the edge, in groups at one time, or individually at
10、different timesWeight: determines the minimum number of tokens that must traverse the edge at the same timeIn this example we use a non-constant weight: an invoice for a particular job can only be sent when all of its tasks have been completed21Activity edges (2)Two kinds of edges:Control flow edge
11、- is an edge which starts an activity node after the completion of the previous one by passing a control tokenObject flow edge - models the flow of values to or from object nodes by passing object or data tokensNotation without activity nodesNotation without activity nodes22Control nodes decision no
12、desRoute the flow to one of the outgoing edges (tokens are not duplicated)Guards are specified on the outgoing edges or with the stereotype decisionInputThere is also the predefined guard else, chosen only if the token is not accepted by all the other edgesIf all the guards fail, the token remains a
13、t the source object node until one of the guards accept it23Control nodes merge nodesBring together multiple alternate flowsAll controls and data arriving at a merge node are immediately passed to the outgoing edgeThere is no synchronization of flows or joining of tokens24Control nodes fork nodesFor
14、k nodes split flows into multiple concurrent flows (tokens are duplicated)25Control nodes join nodesJoin nodes synchronize multiple flowsGenerally, controls or data must be available on every incoming edge in order to be passed to the outgoing edge, but user can specify different conditions under wh
15、ich a join accepts incoming controls and data using a join specification Control nodes final nodesFlow final:destroys the tokens that arrive into itthe activity is terminated when all tokens in the graph are destroyed行为模型建模建立活动图确定活动图的上下文环境 界定业务流程的处理界限 分析业务流程中的主要处理步骤 分析业务流程中的主要数据流 进行职责分配,将业务流程的处理步骤划分
16、到不同的泳道,并将处理步骤和数据流的传递组织起来,建立活动图 添加活动图的详细信息,完善活动图描述 行为模型建模建立活动图复杂流程 More Activity Diagram ElementsSee 30Object nodesHold data temporarily while they wait to move through the graphSpecify the type of values they can hold (if no type is specified, they can hold values of any type)Can also specify the st
17、ate of the held objectsThere are four kinds of object nodes:Pins(three differents notations)Activity Parameter NodesCentral Buffer NodesData Store Nodes31Object nodes centralBufferA central buffer node is an object node that manages flows from multiple sources and destinations (as opposed to pins an
18、d parameters) Acts as a buffer for multiple input flows and output flows Is not tied to an action like pins, or to an activity like activity parameter nodesThe centralBuffer node collects the object Parts, and each Part can be used or packet (but not both)32Object nodes datastoreIs a specific centra
19、l buffer node which stores objects persistently Keeps all tokens that enter into itTokens chosen to move downstream are copied so that tokens never leave the data storeIf arrives a token containing an object already present in the data store, this replaces the old oneTokens in a data store node cann
20、ot be removed (they are removed when the activity is terminated)33Object nodes - multiplicities and upperBoundMultiplicities: specify the minimum (0) and maximum number of values each pin accepts or provides at each invocation of the action:when is available the minimum number of values, the action
21、can startif there is more values than the maximum, the action takes only the first maximum valueUpperBound: shows the maximum number of values that an object node can hold: at runtime, when the upper bound has been reached, the flow is stopped (buffering)34Object nodes effect and orderingEffect: pin
22、s can be notated with the effect that their actions have on objects that move through the pinThe effects can be: create (only on output pins), read, update or delete (only on input pins)Ordering: specifies the order in which the tokens of an object node are offered to the outgoing edges (FIFO, LIFO
23、or modeler-defined ordering)35Special kind of pins (1)Streaming Parameters (notated with STREAM): accept or provide one or more values while an action is executingException Output Parameters (notated with a triangle)Provide values to the exclusion of any other output parameter or outgoing control of
24、 the actionThe action must immediately terminate, and the output cannot quitSpecial kind of pins (2)Parameter Setsgroup of parametersthe action can only accept inputsfrom the pins in one of the setsthe action can only provide outputsto the pins in one of the setsValuePin: special kind of input pin d
25、efined to provide constant values (the type of specificated value must be compatible with the type of the value pin)Compute circumference3.14RayvalueOutput is provided only to the first or to the second setActivity edges presentation optionsAn edge can also be notated using a connectorEvery connecto
26、r with a given label must be paired with exactly one other with the same label on the same activity diagramis equivalent toTo reduce clutter in complex diagrams, object nodes may be elidedis equivalent to38Activity edges - transformationIt is possible to apply a transformation of tokens as they move
27、 across an object flow edge (each order is passed to the transformation behaviour and replaced with the result)In this example, the transformation gets the value of the attribute Customer of the Order objecttransformation specificationSelectionSpecifies the order (FIFO, LIFO or modeler-defined order
28、ing) in which tokens in the node are offered to the outgoing edgesCan be applied to:Object node - specifies the object node ordering, choosing what token offers to the outgoing edge whenever it asks a tokenEdge - chooses the order on which tokens are offered from the source object node to the edge (
29、overrides any selection present on the object node, that is object node ordering)40Token competitionA parameter node or pin may have multiple edges coming out of it, whereupon there will be competition for its tokens, because object nodes cannot duplicate tokens while forks canThen there is indeterm
30、inacy in the movement of data in the graph41ActivityPartition (1)Partitions divide the nodes and edges for identifying actions that have some characteristics in commonThey often correspond to organizational units in a business modelPartitions can be hierarchical and multidimensionalAdditional notati
31、on is provided: placing the partition name in parenthesis above the activity name42ActivityPartition (2)Partition notated to occur outside the primary concern of the modelPre & post condition (1)Can be referred to an activity or to an action (local condition)45Pre & post condition (2)46SendSignalAct
32、ionCreates a signal instance from its inputs, and transmits it to the target object (local or remote)A signal is an asynchronous stimulus that triggers a reaction in the receiver in an asynchronous way and without a replyAny reply message is ignoredTime triggers and Time eventsA Time trigger is a tr
33、igger that specifies when a time event will be generatedTime events occur at the instant when a specified point in time has transpiredThis time may be relative or absoluteRelative time trigger: is specified with the keyword after followed by an expression that evaluates to a time valueAbsolute time
34、trigger: is specified as an expression that evaluates to a time valueJan, 1, 2000, Noonafter (5 seconds)Relative time triggerAbsolute time triggerAcceptEventActionWaits for the occurrence of an event meeting specified conditionsTwo kinds of AcceptEventAction:Accept event action accepts signal events
35、 generated by a SendSignalActionWait time action accepts time eventsAccept event actionWait time actionThe objects stored in Personnel are only retrieved when the join succeeds (only once a year)49InterruptibleActivityRegionIs an activity group (sets of nodes and edges) that supports termination of
36、tokens flowing into itWhen a token leaves an interruptible region via interrupting edges, all tokens and behaviours in the region are terminatedToken transfer is still atomic: a token transition is never partial; it is either complete or it does not happen at all (also for internal stream)Interrupti
37、ng edgeExceptionsException handler - specifies the code to be executed when the specified exception occurs during the execution of the protected nodeWhen an exception occurs the set of execution handlers on the action is examined to look for a handler that matches (catches) the exception If the exce
38、ption is not caught, it is propagated to the enclosing protected node, if one existsIf the exception propagates to the topmost level of the system and is not caught, the behaviour of the system is unspecified; profiles may specify what happens in such cases51ExpansionRegion (1)Nested region of an ac
39、tivity in which each input is a collection of valuesThe expansion region is executed once for each element (or position) in the input collectionOn each execution of the region, an output value from the region is inserted into an output collection at the same position as the input elements52Expansion
40、Region (2)There are three ways of interaction between the executions:Parallel (concurrent): all the interactions are independentIterative: the interactions occur in the order of the elements (the executions of the region must happen in sequence, with one finishing before another can begin)Stream (st
41、reaming): there is a single execution of the region, where the values in the input collection are extracted and placed into the execution of the expansion region as a stream (in order if the collection is ordered)Parameter nameParameter nameParameter nameOutput parameterActivity nodesActivity edgesI
42、nput parameterActivitiesAn activity is the specification of parameterized behaviour as the coordinated sequencing of subordinate units whose individual elements are actionsUses parameters to receive and provide data to the invokerAn action can invoke an activity to describe its action more finelyThi
43、s action invokes the activity Fill Order主要内容面向对象分析用例模型(行为模型)业务流程建模:活动图(行为模型)用例实现(交互):顺序图(行为模型)行为建模:状态图对象模型对象约束语言OCL面向对象建模4. 行为模型交互图交互图以一组对象为中心的交互描述技术 描述在特定上下文环境中一组对象的交互行为 通常描述的是单个用例的典型场景交互图中的每一个交互都描述了环境中的对象为了实现某个目标而执行的一系列消息交换 顺序图和通信图是最常用的 交互图交互图中出现的对象应该在领域模型中有相应的对象存在 4. 行为模型 交互图顺序图4. 行为模型 交互图通信图消息se
44、quence-expression:message messageattribute=name(argument):return-value sequence-expression label iteration-expression iteration-expression *iteration-clause|condition-clause redisplay ()message1: displayPositions (window)1.1 *i := 1.n: drawSegment (i): Controller: Windowwire :Wirenew: Lineleft : Bea
45、dright : Bead1.1.1a: r0 := position ()1.1.1b: r1 := position ()wirelocal linecontents newwindowselfwindow parameter1.1.2: create (r0, r1)1.1.3: display (window) add (self)object symbollink symbolstandard stereotypestandard stereotypestandard stereotypestandard constraintstandard constraint4. 行为模型 交互
46、图系统顺序图将整个系统看作一个黑箱的对象,强调外部参与者和系统的交互行为,重点展示系统级事件 Depicting a Fragment Graphicallysd sampleclientorderinventoryreqLocate itemoperatorop1InteractionFragment InteractionFragmentOperationName:(e.g. loop)Interaction FragmentOperandExampleOptionsarchive(msg)msg : Message: DatabaseoptDo something.msg.status=
47、confirmedFragmentConditionUsed for modeling simple optional blocks.Has one operand; no else guard.Alternativesarchive(msg)msg : Message: DatabaseCondition: Adminaltnotify(msg.getID()wait()msg.status=confirmedmsg.status=errorelseElse condition(optional)Alternative Fragment groupExecution regions. At
48、most one will execute.LoopsDisplay() : OS: Folder: FilelooploopDisplay()for each Folderfor each FileLoop FragmentConditionNested Loop FragmentBreaksisLooged = login(name,pass) : User: User Manager : PolicyaddBadLogin(name)breakisLoogedDo somethingDo something If the condition is met, the break fragm
49、ent is executed, and the reminder of the sequence is ignoredHandy in model exception handlingReferencing a diagramlogin(name,pass) : User: User Manager : PolicyLogin Handling(user,pass) :boolrefDo somethingDo something Reference GateReferenced Diagram: User Manager: UserAccountsd Login Handlingloopc
50、Name -= getUseNamer()for each UserAccountlogin(name,pass)optcName = namecName -= getUseNamer()isInSystem(true)truefalseDiagram nameInput messageOutput messageParallel FragmentsprovideDetails() : User: Checkout Handler : Shipping HandlerperformCheckout() : Transaction HandlerparShip(address,products)
51、provideDetails()chargeMoney(CC,sum)建立交互图建立典型场景的系统顺序图(1)确定系统顺序图的上下文环境(2)找出参与交互的对象。(3)根据发现的对象建立交互图框架。将对象平行排列,并添加对象的生命线。(4)添加消息,描述交互行为。以消息的方式,将对象之间的交互行为描述出来,并建立行为之间的顺序。建立交互图建立用例(多场景)系统顺序图先为主流程场景建立基础的系统顺序图,然后根据分支场景与异常场景的分支点、异常点,建立组合片段描述建立交互图建立详细顺序图简单项目:系统顺序图复杂项目,系统顺序图粒度太大,可以考虑适度使用详细顺序图建立详细顺序图的关键是正确识别参与交
52、互的对象,这个可以借鉴领域模型的工作详细顺序图仍然只是分析模型,不要添加设计因素建立交互图,发现需求缺陷建立交互图时最常发现的问题是系统的交互行为缺失。组合片段和消息描述可能会发现行为数据的问题。如果一个交互消息的数据内容在领域模型中没有描述,就意味着其数据内容是缺失的。如果组合片段监护条件使用的数据内容在领域模型中没有描述,也意味着其数据内容的缺失。主要内容面向对象分析用例模型(行为模型)业务流程建模:活动图(行为模型)用例实现(交互):顺序图(行为模型)行为建模:状态图对象模型对象约束语言OCL面向对象建模4. 行为模型 状态图状态图以状态机理论为基础建立的对系统行为的描述手段状态机是以“
53、状态”概念为基础解释系统行为的一种技术有限状态机FSM(Finite State Machine)是用于建模的最简单的状态机在FSM技术基础之上,发展出了多种分支技术(FSM,STD,Yourdon,SDL,STM,SC),UML的状态图SD(State Diagram) 也是其中之一。主要用于描述重要而且复杂的对象的所有行为这个对象的行为通常要涉及很多(甚至大部分)的用例4. 行为模型 状态图状态机理论状态机理论认为,系统总是处于一定的状态之中。而且,在某一时刻,系统只能处于一种状态之中。系统在任何一个状态中都是稳定的,如果没有外部事件触发,系统会一直持续维持该状态。如果发生有效的触发事件,
54、系统将会响应事件,从一种状态转移到唯一的另一种状态。如果能够罗列出系统所有可能的状态,并发现所有有效的外部事件,那么就能够从状态转移的角度完整的表达系统的所有行为 DefinitionA finite automata is a 5-tuple (Q, , , q0, F), whereQ is a finite set called the states, is a finite set called the alphabet (inputs), : Q Q is the transition function, q0 Q is the start state, and F Q is the
55、 set of accept states (final states).4. 行为模型 状态图简单示例Readystop/ctr := 0Stop normal状态触发行为开始状态转换结束状态Done监护条件事件Example: UML State chart DiagramsState Machine DiagramsCompound States - A state machine diagram may include sub-machine diagrams, as in the example below.Alternative way to show the same infor
56、mationThe symbol indicates that details of the Check PIN sub-machine are shown in a separate diagram.Entry Point - Sometimes you wont want to enter a sub-machine at the normal initial state. Exit Point - In a similar manner to entry points, it is possible to have named alternative exit points. State
57、 Machine DiagramsState Machine DiagramsChoice Pseudo-State - A choice pseudo-state is shown as a diamond with one transition arriving and two or more transitions leaving. State Machine DiagramsJunction Pseudo-State - Junction pseudo-states are used to chain together multiple transitions. A single ju
58、nction can have one or more incoming, and one or more outgoing, transitions; Terminate Pseudo-State - Entering a terminate pseudo-state indicates that the lifeline of the state machine has ended. State Machine DiagramsHistory States - A history state is used to remember the previous state of a state
59、 machine when it was interrupted. UML SD详细的使用见:表142、UML的状态图表示法行为模型建模建立状态图确定上下文环境 搞清楚状态的主体常见的状态主体有:类、用例、多个用例和整个系统 识别状态,标记初始状态和结束状态可能会不存在确定的初始状态和结束状态 建立状态转换 补充详细信息,完善状态图 状态数量较多时,考虑建立层次结构(状态或)或并发结构(状态与)行为模型建模建立状态图授权空闲销售开始商品信息显示错误提示列表显示销售结束授权YY空闲YYYY销售开始Y商品信息显示YY错误提示Y列表显示Y销售结束Y建立状态图,发现需求缺陷如果状态图中发现有无法进入的
60、状态或者无法跳出的状态,就意味着相应行为的缺失如果一个状态在发生触发时转移路线不确定,就意味着监护条件数据缺失或者行为需要细化如果应该建立的状态转移在需求内容中没有体现,就需要修正需求内容如果应该存在的状态在需求内容中没有体现,也需要修正需求内容主要内容面向对象分析用例模型(行为模型)业务流程建模:活动图(行为模型)用例实现(交互):顺序图(行为模型)行为建模:状态图对象模型对象约束语言OCL面向对象建模6.1 对象模型组成元素对象对象对象是指在一个应用当中具有明确角色的独立可确认的实体 每个对象都要包含标识唯一的标识自己,引用 状态对象的特征描述,包括对象的属性和属性的取值 行为对象在其状态
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年初中生物学考试试题及答案
- 劳动教育融入研学旅行中的研究
- 市场推广及市场调研协议
- 教学进度管理规定
- 动物王国的童话读后感(15篇)
- 2025年采购师(初级)考试试卷:采购谈判与议价技巧
- 2025年电工中级职业技能考试真题卷-电路分析与应用试题
- 社区开发与农业产业化合作协议
- 2025年柔印CTP项目规划申请报告模板
- 春节里的趣事记事类话题作文13篇
- 2025年电缆保护拖链行业深度研究分析报告
- 5E教学模式研究现状与提升策略
- 2024年粮油仓储管理员理论知识竞赛理论考试题库500题(含答案)
- 2025年水稳材料购销合同范本(适用于机场跑道建设)3篇
- Web应用的自动化测试研究
- 《急慢性扁桃体炎》课件
- 脑外伤病人应急演练
- T-FSS 81-2023 佛山标准 食品包装用玻璃瓶罐
- 储气罐技术说明
- 广东开放大学Java程序设计基础(专)单元测试1-7答案
- 2024年《招标采购专业知识与法律法规》考前必刷必练题库500题(含真题、必会题)
评论
0/150
提交评论