KEMBAR78
C:\documents and settings\student\desktop\swaroop uml | PPT
Short Introduction into UML Use Cases, State Charts and Activity Charts
UML Overview Behavioral Elements Model  Management Foundation Use Cases State Machines Activity Graphs Collaborations Common Behavior
Use Case Modeling What is use case modeling? Core concepts Diagram tour When to model use cases Modeling tips Example: Online HR System
What is use case modeling? use case model: a view of a system that emphasizes the behavior as it appears to outside users. A use case model partitions system functionality into transactions (‘use cases’) that are meaningful to users (‘actors’).
Use Case Modeling:  Core Elements
Use Case Modeling:  Core Relationships << extend >>
Use Case Modeling:  Core Relationships  (cont’d) << include >>
Shows use cases, actor and their relationships Use case internals can be specified by text and/or interaction diagrams Kinds use case diagram use case description Use Case Diagram Tour
Use Case Diagram Fig. 3-53,  UML Notation Guide
Use Case Relationships Fig. 3-54,  UML Notation Guide
Actor Relationships Fig. 3-55,  UML Notation Guide
Use Case Description: Change Flight Actors:  traveler, client account db, airline reservation system Preconditions: Traveler has logged on to the system and selected ‘change flight itinerary’ option Basic course System retrieves traveler’s account and flight itinerary from client account database System asks traveler to select itinerary segment she wants to change; traveler selects itinerary segment. System asks traveler for new departure and destination information; traveler provides information. If flights are available then … System displays transaction summary. Alternative courses If no flights are available then …
When to model use cases Model user requirements with use cases. Model test scenarios with use cases. If you are using a use-case driven method start with use cases and derive your structural and behavioral models from it. If you are not using a use-case driven method make sure that your use cases are consistent with your structural and behavioral models.
Use Case Modeling Tips Make sure that each use case describes a significant chunk of system usage that is understandable by both domain experts and programmers When defining use cases in text, use nouns and verbs accurately and consistently to help derive objects and messages for interaction diagrams Factor out common usages that are required by multiple use cases If the usage is required use <<include>> If the base use case is complete and the usage may be optional, consider use <<extend>> A use case diagram should contain only use cases at the same level of abstraction include only actors who are required Large numbers of use cases should be organized into packages
Example: Online HR System
Online HR System: Use Case Relationships
Online HR System: Update Benefits Use Case   Actors :  employee, employee account db, healthcare plan system, insurance plan system Preconditions: Employee has logged on to the system and selected ‘update benefits’ option Basic course System retrieves employee account from employee account db System asks employee to select medical plan type;  include  Update Medical Plan. System asks employee to select dental plan type;  include  Update Dental Plan. … Alternative courses If health plan is not available in the employee’s area the employee is informed and asked to select another plan...
State Machines Overview Basic State Machine Concepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
Automata A machine whose output behavior is not only a direct consequence of the current input, but of some past history of its inputs  Characterized by an internal state which represents this past experience ON ON ON ON OFF
State Machine (Automaton) Diagram Graphical rendering of automata behavior Lamp On Lamp Off off on off on
Outputs and Actions As the automaton changes state it can generate outputs: on off Lamp On print(”on”) Lamp  Off off on Moore  automaton on off Lamp On Lamp  Off off on/ print(”on”) Mealy  automaton
Extended State Machines Addition of variables (“extended state”) ctr : Integer off on Lamp On Lamp Off off on/ ctr := ctr + 1
A Bit of Theory An extended (Mealy) state machine is defined by: a set of input signals (input alphabet) a set of output signals (output alphabet) a set of states a set of transitions triggering signal action a set of extended state variables an initial state designation a set of final states (if terminating automaton)
Basic UML Statechart Diagram Ready /ctr := 0 stop State Trigger Action Initial  pseudostate Transition Final  state Done “ top” state top stop
What Kind of Behavior? In general, state machines are suitable for describing event-driven, discrete behavior inappropriate for modeling continuous behavior time threshold
Event-Driven Behavior Event = a type of observable occurrence interactions: synchronous object operation invocation (call event) asynchronous signal reception (signal event) occurrence of time instants (time event) interval expiry calendar/clock time change in value of some entity (change event) Event Instance = an instance of an event (type) occurs at a particular time instant and has no duration
The Behavior of What? In principle, anything that manifests event-driven behavior NB: there is no support currently in UML for modeling continuous behavior In practice: the behavior of individual objects object interactions The dynamic semantics of UML state machines are currently mainly specified for the case of active objects
Basic State Machine Concepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
Object Behavior - General Model Simple server model: Handle Request Initialize Object Terminate Object Wait for Request Handling depends on  specific request type void:offHook ();   {busy = true;   obj.reqDialtone();   …   };
Object Behavior and State Machines Direct mapping: Handle Event Initialize Object Terminate Object Wait for Event on off Lamp On Lamp  Off off on/print(”on”) stop
Object and Threads Passive objects:  depend on external power (thread of execution) Active objects:  self-powered (own thread of execution) Handle Request Initialize Object Terminate Object Wait for Request Handle Request Initialize Object Terminate Object Wait for Request
Passive Objects: Dynamic Semantics Encapsulation does not protect the object from concurrency conflicts! Explicit synchronization is still required Handle Request Initialize Object Terminate Object Wait for Request
Active Objects and State Machines Objects that encapsulate own thread of execution start/^master.ready() anActiveObject #currentEvent : Event + start ( ) + poll ( ) + stop ( ) created ready start/^master.ready() poll/^master.ack() stop/ poll/defer ready created start ready
Active Objects: Dynamic Semantics Run-to-completion model:   serialized event handling  eliminates internal concurrency minimal context switching overhead ActiveObject:
The Run-to-Completion Model A high priority event for (another) active object will preempt an active object that is handling a low-priority event Active1 Active2 hi hi lo
Basic State Machine Concepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
State Entry and Exit Actions A dynamic assertion mechanism entry/lamp.on(); exit/lamp.off(); LampOn e1 e2
Order of Actions: Simple Case Exit actions prefix transition actions Entry action postfix transition actions Resulting action sequence: printf(“exiting”); printf(“to off”); lamp.off(); printf(“exiting”); printf(“needless”); lamp.off(); off/printf(“needless”); off/printf(“to off”); LampOff entry/lamp.off(); exit/printf(“exiting”); LampOn entry/lamp.on(); exit/printf(“exiting”);
Internal Transitions Self-transitions that bypass entry and exit actions off/null; Internal transition triggered by  an “off” event LampOff entry/lamp.off(); exit/printf(“exiting”);
State (“Do”) Activities Forks a concurrent thread that executes until: the action completes or the state is exited through an outgoing transition do/while (true) alarm.ring(); “ do” activity Error entry/printf(“error!”)
Guards Conditional execution of transitions guards (Boolean predicates) must be side-effect free Selling Unhappy Happy bid  [(value >= 100) & (value < 200)]  /sell bid  [value >= 200]  /sell bid  [value < 100]  /reject
Static Conditional Branching Merely a graphical shortcut for convenient rendering of decision trees [(value >= 100) & (value < 200)]  /sell [value >= 200]  /sell [value < 100]  /reject Selling Unhappy Happy bid
Dynamic Conditional Branching Choice pseudostate: guards are evaluated at the instant when the decision point is reached  bid / gain := calculatePotentialGain(value) [(gain >= 100) & (gain < 200)]  /sell [gain >= 200]  /sell [gain < 100]  /reject Dynamic choicepoint Selling Unhappy Happy
Hierarchical State Machines Graduated attack on complexity states decomposed into state machines LampFlashing flash/ 1sec/ 1sec/ FlashOff entry/lamp.off() FlashOn entry/lamp.on() off/ LampOff entry/lamp.off() LampOn entry/lamp.on() on/ on/ on/
“ Stub” Notation Notational shortcut: no semantic significance LampFlashing flash/ on/ FlashOn FlashOff off/ LampOff entry/lamp.off() LampOn entry/lamp.on() on/ on/
Group Transitions Higher-level transitions LampFlashing Default transition to the initial pseudostate Group transition 1sec/ 1sec/ FlashOff entry/lamp.off() FlashOn entry/lamp.on() off/ LampOff entry/lamp.off() LampOn entry/lamp.on() on/ flash/ on/
Completion Transitions Triggered by a completion event generated automatically when an immediately nested state machine terminates completion  transition (no trigger) Committing Phase1 Phase2 CommitDone
Triggering Rules Two or more transitions may have the same event trigger innermost transition takes precedence event is discarded whether or not it triggers a transition LampFlashing off/ FlashOff FlashOn on/ on/
Deferred Events Events can be retained if they do not trigger a transition off/ on/ LampOff entry/lamp.off() off/defer Deferred event LampOn entry/lamp.on()
Order of Actions: Complex Case Same approach as for the simple case initS2 E/actE Actions execution sequence: exS11     exS1    actE      enS2    initS2    enS21 S1 exit/exS1 S11 exit/exS11 S2 entry/enS2 S21 entry/enS21
History Return to a previously visited hierarchical state deep and shallow history options Diagnosing Diagnostic1 Diagnostic2 suspend/ Step11 Step12 Step21 Step22 resume/ H*
Orthogonality Multiple simultaneous perspectives on the same entity Child Adult Retiree age Poor Rich financialStatus
Orthogonal Regions Combine multiple simultaneous descriptions Child Adult Retiree age Poor Rich financialStatus Poor Rich financialStatus Child Adult Retiree age
Orthogonal Regions - Semantics All mutually orthogonal regions detect the same events and respond to them “simultaneously” usually reduces to interleaving of some kind  Outlaw LawAbiding Poor Rich financialStatus legalStatus robBank/ robBank/
Interactions Between Regions Typically through shared variables or awareness of other regions’ state changes sane : Boolean flying : Boolean Catch22 sanityStatus flightStatus (flying)/ Crazy entry/sane := false; Sane entry/sane := true; request Grounding/ Flying entry/flying := true; Grounded entry/flying := false; (sane)/ (~sane)/
Transition Forks and Joins For transitions into/out of orthogonal regions: Staff Member employee Child Adult Retiree age Manager
Common Misuse of Orthogonality Using regions to model independent objects Child Adult Retiree Child Adult Retiree Person1 Person2 Person1 Person2
Basic State Machine Concepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
Wrap Up: Statecharts UML uses an object-oriented variant of Harel’s statecharts adjusted to software modeling needs Used to model event-driven (reactive) behavior well-suited to the server model inherent in the object paradigm Primary use for modeling the behavior of active event-driven objects systems modeled as networks of collaborating state machines run-to-completion paradigm significantly simplifies concurrency management
Wrap Up: Statecharts (cont’d) Includes a number of sophisticated features that realize common state-machine usage patterns: entry/exit actions state activities dynamic and static conditional branching Also, provides hierarchical modeling for dealing with very complex systems hierarchical states hierarchical transitions orthogonality
Activity Diagram Applications Intended for applications that need control flow or object/data flow models … ... rather than event-driven models like state machines. For example: business process modeling and workflow. The difference in the three models is how step in a process is initiated, especially with respect to how the step gets its inputs.
Activity Diagrams Based on State Machines Currently activity graphs are modeled as a kind of state machine. Modeler doesn't normally need to be aware of this sleight-of-hand ... ... but will notice that &quot;state&quot; is used in the element names. Activity graphs will become independent of state machines in UML 2.0.
Just like their state machine counterparts (simple state and submachine state) except that ... ... transitions coming out of them are taken when the step is finished, rather than being triggered by a external event, ... ... and they support  dynamic concurrency. Kinds of Steps in Activity Diagrams Action Action (State) Subactivity Subactivity (State)
Action (State) An action is used for anything that does not directly start another activity graph, like invoking an operation on an object, or running a user-specified action. However, an action can invoke an operation that has another activity graph as a method (possible polymorphism). Action
Subactivity (State) A subactivity (state) starts another activity graph without using an operation. Used for functional decomposition, non-polymorphic applications, like many workflow systems. The invoked activity graph can be used by many subactivity states. Subactivity
Example POEmployee.sortMail Deliver Mail POEmployee sortMail() Check Out Truck Put Mail In Boxes Deliver Mail
Activity Graph as Method Application is completely OO when all action states invoke operations All activity graphs are methods for operations. POEmployee sortMail() POEmployee.sortMail POEmployee.deliverMail deliverMail() «realize» Check Out Truck Put Mail In Boxes PO Employee Deliver Mail Method
Dynamic concurrency Applies to actions and subactivities. Not inherited from state machines. Invokes an action or subactivity any number of times in parallel, as determined by an expression evaluated at runtime.  Expression also determines arguments. Upper right-hand corner  shows a multiplicity restricting the number of parallel invocations. Outgoing transition triggered when all invocations are done. Currently no standard notation for concurrency expression or how arguments are accessed by actions.  Attach a note as workaround for expression.  Issue for UML 2.0. Action/Subactivity *
Object Flow (State) A special sort of step (state) that represents the availability of a particular kind of object, perhaps in a particular state. No action or subactivity is invoked and control passes immediately to the next step (state). Places constraints on input and output parameters of steps before and after it. Class [State]
Object Flow (State) Take Order must have an output parameter giving an order, or one of its subtypes. Fill Order must have an input parameter taking an order, or one of its supertypes. Dashed lines used with object flow have the same semantics as any other state transition. Order [Taken] Take Order Fill Order
Coordinating Steps Inherited from state machines Initial state Final state Fork and join
Decision point and merge (  ) are inherited from state machines. For modeling conventional flow chart decisions. Coordinating Steps Calculate Cost Charge Account Get Authorization [cost < $50] [cost >= $50]
Synch state (  ) is inherited from state machines but used mostly in activity graphs. Provides communication capability between parallel processes. Coordinating Steps State machine notation Inspect Install Foundation Build Frame Install Electricity in Foundation Put On Roof Install Electricity In Frame Install Electricity Outside Install Walls * *
Convenience Features (Synch State) Forks and joins do not require composite states. Synch states may be omitted for the common case (unlimited bound and one incoming and outgoing transition). Activity diagram notation Build Frame Install Foundation Install Electricity in Foundation Put On Roof Install Electricity In Frame Install Electricity Outside Install Walls Inspect
Convenience Features (Synch State) Object flow states can be synch states
Convenience Features Fork transitions can have guards. Instead of doing this: Register Bug Evaluate Impact Fix Bug Revise Plan Release Fix Test Fix [ priority = 1] Register Bug Evaluate Impact Fix Bug Revise Plan Release Fix Test Fix [ priority = 1] [else]
Convenience Features Partitions are a grouping mechanism. Swimlanes are the notation for partitions. They do not provide domain-specific semantics. Tools can generate swimlane presentation from domain-specific information without partitions. Register Bug Evaluate Impact Fix Bug Revise Plan Release Fix Test Fix [ priority = 1] Management Support Engineering
Convenience Features Signal send icon Signal …  translates to a transition with a send action. Signal receipt icon …  translates to a wait state (a state with no action and a signal trigger event). Coffee Pot Wake Up Get Cups Turn on Coffee Pot Coffee Done Drink Coffee Signal
Case Study Adapted from Kobryn, “UML 2001” Communications of the ACM October 1999 partition Submission Team Task Force Revision Task Force Issue RFP Evaluate initial submissions Submit specification draft Collaborate with competitive submitters Develop technology specification action state RFP [issued] [optional] control flow Finalize specification Specification [initial proposal] input value Begin object flow initial state join of control conditional fork fork of control Specification [final proposal]
Case Study Adapted from Kobryn, “UML 2001” Communications of the ACM October 1999 Evaluate initial submissions Evaluate final submissions Vote to recommend Enhance specification Implement specification Revise specification Finalize specification Specification [final proposal] Specification [adopted] Recommend revision Specification [revised] [NO] [YES] [else] [Enhanced] decision final state guard Collaborate with competitive submitters
When to Use Activity Diagrams Use activity diagrams when the behavior you are modeling ... does not depend much on external events. mostly has steps that run to completion, rather than being interrupted by events.  requires object/data flow between steps. is being constructed at a stage when you are more concerned with which activities happen, rather than which objects are responsible for them (except partitions possibly).
Activity Diagram Modeling Tips Control flow and object flow are not separate.  Both are modeled with state transitions. Dashed object flow lines are also control flow.  You can mix state machine and control/object flow constructs on the same diagram (though you probably do not want to).
Activity Diagram Modeling Tips From UML User Guide: Request Return Get Return Number Ship Item Item [returned] Receive Item Restock Item Credit Account Item [available] Customer Telesales Warehouse Accounting
Activity Modeling Tips Request Return Get Return Number Ship Item Item [returned] Receive Item Restock Item Credit Account Item [available] Customer Telesales Warehouse Accounting
Activity Diagram Modeling Tips Activity diagrams inherit from state machines the requirement for well-structured nesting of composite states. This means you should either model as if composite states were there by matching all forks/decisions with a correspond join/merges … …  or check that the diagram can be translated to one that is well-nested. This insures that diagram is executable under state machine semantics.
Activity Diagram Modeling Tips Well-nested:
Activity Diagram Modeling Tips Not well-nested: Apply structured coding principles. (Be careful with goto’s!)
Activity Diagram Modeling Tips Can be translated to well-nested diagram on earlier slide:
Wrap Up: Activity Diagrams Use Activity Diagrams for applications that are primarily control and data-driven, like business modeling … …  rather than event-driven applications like embedded systems. Activity diagrams are a kind of state machine until UML 2.0 … …  so control and object/data flow do not have separate semantics. UML 1.3 has new features for business modeling that increase power and convenience.  Check it out and give feedback!

C:\documents and settings\student\desktop\swaroop uml

  • 1.
    Short Introduction intoUML Use Cases, State Charts and Activity Charts
  • 2.
    UML Overview BehavioralElements Model Management Foundation Use Cases State Machines Activity Graphs Collaborations Common Behavior
  • 3.
    Use Case ModelingWhat is use case modeling? Core concepts Diagram tour When to model use cases Modeling tips Example: Online HR System
  • 4.
    What is usecase modeling? use case model: a view of a system that emphasizes the behavior as it appears to outside users. A use case model partitions system functionality into transactions (‘use cases’) that are meaningful to users (‘actors’).
  • 5.
    Use Case Modeling: Core Elements
  • 6.
    Use Case Modeling: Core Relationships << extend >>
  • 7.
    Use Case Modeling: Core Relationships (cont’d) << include >>
  • 8.
    Shows use cases,actor and their relationships Use case internals can be specified by text and/or interaction diagrams Kinds use case diagram use case description Use Case Diagram Tour
  • 9.
    Use Case DiagramFig. 3-53, UML Notation Guide
  • 10.
    Use Case RelationshipsFig. 3-54, UML Notation Guide
  • 11.
    Actor Relationships Fig.3-55, UML Notation Guide
  • 12.
    Use Case Description:Change Flight Actors: traveler, client account db, airline reservation system Preconditions: Traveler has logged on to the system and selected ‘change flight itinerary’ option Basic course System retrieves traveler’s account and flight itinerary from client account database System asks traveler to select itinerary segment she wants to change; traveler selects itinerary segment. System asks traveler for new departure and destination information; traveler provides information. If flights are available then … System displays transaction summary. Alternative courses If no flights are available then …
  • 13.
    When to modeluse cases Model user requirements with use cases. Model test scenarios with use cases. If you are using a use-case driven method start with use cases and derive your structural and behavioral models from it. If you are not using a use-case driven method make sure that your use cases are consistent with your structural and behavioral models.
  • 14.
    Use Case ModelingTips Make sure that each use case describes a significant chunk of system usage that is understandable by both domain experts and programmers When defining use cases in text, use nouns and verbs accurately and consistently to help derive objects and messages for interaction diagrams Factor out common usages that are required by multiple use cases If the usage is required use <<include>> If the base use case is complete and the usage may be optional, consider use <<extend>> A use case diagram should contain only use cases at the same level of abstraction include only actors who are required Large numbers of use cases should be organized into packages
  • 15.
  • 16.
    Online HR System:Use Case Relationships
  • 17.
    Online HR System:Update Benefits Use Case Actors : employee, employee account db, healthcare plan system, insurance plan system Preconditions: Employee has logged on to the system and selected ‘update benefits’ option Basic course System retrieves employee account from employee account db System asks employee to select medical plan type; include Update Medical Plan. System asks employee to select dental plan type; include Update Dental Plan. … Alternative courses If health plan is not available in the employee’s area the employee is informed and asked to select another plan...
  • 18.
    State Machines OverviewBasic State Machine Concepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
  • 19.
    Automata A machinewhose output behavior is not only a direct consequence of the current input, but of some past history of its inputs Characterized by an internal state which represents this past experience ON ON ON ON OFF
  • 20.
    State Machine (Automaton)Diagram Graphical rendering of automata behavior Lamp On Lamp Off off on off on
  • 21.
    Outputs and ActionsAs the automaton changes state it can generate outputs: on off Lamp On print(”on”) Lamp Off off on Moore automaton on off Lamp On Lamp Off off on/ print(”on”) Mealy automaton
  • 22.
    Extended State MachinesAddition of variables (“extended state”) ctr : Integer off on Lamp On Lamp Off off on/ ctr := ctr + 1
  • 23.
    A Bit ofTheory An extended (Mealy) state machine is defined by: a set of input signals (input alphabet) a set of output signals (output alphabet) a set of states a set of transitions triggering signal action a set of extended state variables an initial state designation a set of final states (if terminating automaton)
  • 24.
    Basic UML StatechartDiagram Ready /ctr := 0 stop State Trigger Action Initial pseudostate Transition Final state Done “ top” state top stop
  • 25.
    What Kind ofBehavior? In general, state machines are suitable for describing event-driven, discrete behavior inappropriate for modeling continuous behavior time threshold
  • 26.
    Event-Driven Behavior Event= a type of observable occurrence interactions: synchronous object operation invocation (call event) asynchronous signal reception (signal event) occurrence of time instants (time event) interval expiry calendar/clock time change in value of some entity (change event) Event Instance = an instance of an event (type) occurs at a particular time instant and has no duration
  • 27.
    The Behavior ofWhat? In principle, anything that manifests event-driven behavior NB: there is no support currently in UML for modeling continuous behavior In practice: the behavior of individual objects object interactions The dynamic semantics of UML state machines are currently mainly specified for the case of active objects
  • 28.
    Basic State MachineConcepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
  • 29.
    Object Behavior -General Model Simple server model: Handle Request Initialize Object Terminate Object Wait for Request Handling depends on specific request type void:offHook (); {busy = true; obj.reqDialtone(); … };
  • 30.
    Object Behavior andState Machines Direct mapping: Handle Event Initialize Object Terminate Object Wait for Event on off Lamp On Lamp Off off on/print(”on”) stop
  • 31.
    Object and ThreadsPassive objects: depend on external power (thread of execution) Active objects: self-powered (own thread of execution) Handle Request Initialize Object Terminate Object Wait for Request Handle Request Initialize Object Terminate Object Wait for Request
  • 32.
    Passive Objects: DynamicSemantics Encapsulation does not protect the object from concurrency conflicts! Explicit synchronization is still required Handle Request Initialize Object Terminate Object Wait for Request
  • 33.
    Active Objects andState Machines Objects that encapsulate own thread of execution start/^master.ready() anActiveObject #currentEvent : Event + start ( ) + poll ( ) + stop ( ) created ready start/^master.ready() poll/^master.ack() stop/ poll/defer ready created start ready
  • 34.
    Active Objects: DynamicSemantics Run-to-completion model: serialized event handling eliminates internal concurrency minimal context switching overhead ActiveObject:
  • 35.
    The Run-to-Completion ModelA high priority event for (another) active object will preempt an active object that is handling a low-priority event Active1 Active2 hi hi lo
  • 36.
    Basic State MachineConcepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
  • 37.
    State Entry andExit Actions A dynamic assertion mechanism entry/lamp.on(); exit/lamp.off(); LampOn e1 e2
  • 38.
    Order of Actions:Simple Case Exit actions prefix transition actions Entry action postfix transition actions Resulting action sequence: printf(“exiting”); printf(“to off”); lamp.off(); printf(“exiting”); printf(“needless”); lamp.off(); off/printf(“needless”); off/printf(“to off”); LampOff entry/lamp.off(); exit/printf(“exiting”); LampOn entry/lamp.on(); exit/printf(“exiting”);
  • 39.
    Internal Transitions Self-transitionsthat bypass entry and exit actions off/null; Internal transition triggered by an “off” event LampOff entry/lamp.off(); exit/printf(“exiting”);
  • 40.
    State (“Do”) ActivitiesForks a concurrent thread that executes until: the action completes or the state is exited through an outgoing transition do/while (true) alarm.ring(); “ do” activity Error entry/printf(“error!”)
  • 41.
    Guards Conditional executionof transitions guards (Boolean predicates) must be side-effect free Selling Unhappy Happy bid [(value >= 100) & (value < 200)] /sell bid [value >= 200] /sell bid [value < 100] /reject
  • 42.
    Static Conditional BranchingMerely a graphical shortcut for convenient rendering of decision trees [(value >= 100) & (value < 200)] /sell [value >= 200] /sell [value < 100] /reject Selling Unhappy Happy bid
  • 43.
    Dynamic Conditional BranchingChoice pseudostate: guards are evaluated at the instant when the decision point is reached bid / gain := calculatePotentialGain(value) [(gain >= 100) & (gain < 200)] /sell [gain >= 200] /sell [gain < 100] /reject Dynamic choicepoint Selling Unhappy Happy
  • 44.
    Hierarchical State MachinesGraduated attack on complexity states decomposed into state machines LampFlashing flash/ 1sec/ 1sec/ FlashOff entry/lamp.off() FlashOn entry/lamp.on() off/ LampOff entry/lamp.off() LampOn entry/lamp.on() on/ on/ on/
  • 45.
    “ Stub” NotationNotational shortcut: no semantic significance LampFlashing flash/ on/ FlashOn FlashOff off/ LampOff entry/lamp.off() LampOn entry/lamp.on() on/ on/
  • 46.
    Group Transitions Higher-leveltransitions LampFlashing Default transition to the initial pseudostate Group transition 1sec/ 1sec/ FlashOff entry/lamp.off() FlashOn entry/lamp.on() off/ LampOff entry/lamp.off() LampOn entry/lamp.on() on/ flash/ on/
  • 47.
    Completion Transitions Triggeredby a completion event generated automatically when an immediately nested state machine terminates completion transition (no trigger) Committing Phase1 Phase2 CommitDone
  • 48.
    Triggering Rules Twoor more transitions may have the same event trigger innermost transition takes precedence event is discarded whether or not it triggers a transition LampFlashing off/ FlashOff FlashOn on/ on/
  • 49.
    Deferred Events Eventscan be retained if they do not trigger a transition off/ on/ LampOff entry/lamp.off() off/defer Deferred event LampOn entry/lamp.on()
  • 50.
    Order of Actions:Complex Case Same approach as for the simple case initS2 E/actE Actions execution sequence: exS11  exS1  actE  enS2  initS2  enS21 S1 exit/exS1 S11 exit/exS11 S2 entry/enS2 S21 entry/enS21
  • 51.
    History Return toa previously visited hierarchical state deep and shallow history options Diagnosing Diagnostic1 Diagnostic2 suspend/ Step11 Step12 Step21 Step22 resume/ H*
  • 52.
    Orthogonality Multiple simultaneousperspectives on the same entity Child Adult Retiree age Poor Rich financialStatus
  • 53.
    Orthogonal Regions Combinemultiple simultaneous descriptions Child Adult Retiree age Poor Rich financialStatus Poor Rich financialStatus Child Adult Retiree age
  • 54.
    Orthogonal Regions -Semantics All mutually orthogonal regions detect the same events and respond to them “simultaneously” usually reduces to interleaving of some kind Outlaw LawAbiding Poor Rich financialStatus legalStatus robBank/ robBank/
  • 55.
    Interactions Between RegionsTypically through shared variables or awareness of other regions’ state changes sane : Boolean flying : Boolean Catch22 sanityStatus flightStatus (flying)/ Crazy entry/sane := false; Sane entry/sane := true; request Grounding/ Flying entry/flying := true; Grounded entry/flying := false; (sane)/ (~sane)/
  • 56.
    Transition Forks andJoins For transitions into/out of orthogonal regions: Staff Member employee Child Adult Retiree age Manager
  • 57.
    Common Misuse ofOrthogonality Using regions to model independent objects Child Adult Retiree Child Adult Retiree Person1 Person2 Person1 Person2
  • 58.
    Basic State MachineConcepts Statecharts and Objects Advanced Modeling Concepts Wrap Up
  • 59.
    Wrap Up: StatechartsUML uses an object-oriented variant of Harel’s statecharts adjusted to software modeling needs Used to model event-driven (reactive) behavior well-suited to the server model inherent in the object paradigm Primary use for modeling the behavior of active event-driven objects systems modeled as networks of collaborating state machines run-to-completion paradigm significantly simplifies concurrency management
  • 60.
    Wrap Up: Statecharts(cont’d) Includes a number of sophisticated features that realize common state-machine usage patterns: entry/exit actions state activities dynamic and static conditional branching Also, provides hierarchical modeling for dealing with very complex systems hierarchical states hierarchical transitions orthogonality
  • 61.
    Activity Diagram ApplicationsIntended for applications that need control flow or object/data flow models … ... rather than event-driven models like state machines. For example: business process modeling and workflow. The difference in the three models is how step in a process is initiated, especially with respect to how the step gets its inputs.
  • 62.
    Activity Diagrams Basedon State Machines Currently activity graphs are modeled as a kind of state machine. Modeler doesn't normally need to be aware of this sleight-of-hand ... ... but will notice that &quot;state&quot; is used in the element names. Activity graphs will become independent of state machines in UML 2.0.
  • 63.
    Just like theirstate machine counterparts (simple state and submachine state) except that ... ... transitions coming out of them are taken when the step is finished, rather than being triggered by a external event, ... ... and they support dynamic concurrency. Kinds of Steps in Activity Diagrams Action Action (State) Subactivity Subactivity (State)
  • 64.
    Action (State) Anaction is used for anything that does not directly start another activity graph, like invoking an operation on an object, or running a user-specified action. However, an action can invoke an operation that has another activity graph as a method (possible polymorphism). Action
  • 65.
    Subactivity (State) Asubactivity (state) starts another activity graph without using an operation. Used for functional decomposition, non-polymorphic applications, like many workflow systems. The invoked activity graph can be used by many subactivity states. Subactivity
  • 66.
    Example POEmployee.sortMail DeliverMail POEmployee sortMail() Check Out Truck Put Mail In Boxes Deliver Mail
  • 67.
    Activity Graph asMethod Application is completely OO when all action states invoke operations All activity graphs are methods for operations. POEmployee sortMail() POEmployee.sortMail POEmployee.deliverMail deliverMail() «realize» Check Out Truck Put Mail In Boxes PO Employee Deliver Mail Method
  • 68.
    Dynamic concurrency Appliesto actions and subactivities. Not inherited from state machines. Invokes an action or subactivity any number of times in parallel, as determined by an expression evaluated at runtime. Expression also determines arguments. Upper right-hand corner shows a multiplicity restricting the number of parallel invocations. Outgoing transition triggered when all invocations are done. Currently no standard notation for concurrency expression or how arguments are accessed by actions. Attach a note as workaround for expression. Issue for UML 2.0. Action/Subactivity *
  • 69.
    Object Flow (State)A special sort of step (state) that represents the availability of a particular kind of object, perhaps in a particular state. No action or subactivity is invoked and control passes immediately to the next step (state). Places constraints on input and output parameters of steps before and after it. Class [State]
  • 70.
    Object Flow (State)Take Order must have an output parameter giving an order, or one of its subtypes. Fill Order must have an input parameter taking an order, or one of its supertypes. Dashed lines used with object flow have the same semantics as any other state transition. Order [Taken] Take Order Fill Order
  • 71.
    Coordinating Steps Inheritedfrom state machines Initial state Final state Fork and join
  • 72.
    Decision point andmerge ( ) are inherited from state machines. For modeling conventional flow chart decisions. Coordinating Steps Calculate Cost Charge Account Get Authorization [cost < $50] [cost >= $50]
  • 73.
    Synch state ( ) is inherited from state machines but used mostly in activity graphs. Provides communication capability between parallel processes. Coordinating Steps State machine notation Inspect Install Foundation Build Frame Install Electricity in Foundation Put On Roof Install Electricity In Frame Install Electricity Outside Install Walls * *
  • 74.
    Convenience Features (SynchState) Forks and joins do not require composite states. Synch states may be omitted for the common case (unlimited bound and one incoming and outgoing transition). Activity diagram notation Build Frame Install Foundation Install Electricity in Foundation Put On Roof Install Electricity In Frame Install Electricity Outside Install Walls Inspect
  • 75.
    Convenience Features (SynchState) Object flow states can be synch states
  • 76.
    Convenience Features Forktransitions can have guards. Instead of doing this: Register Bug Evaluate Impact Fix Bug Revise Plan Release Fix Test Fix [ priority = 1] Register Bug Evaluate Impact Fix Bug Revise Plan Release Fix Test Fix [ priority = 1] [else]
  • 77.
    Convenience Features Partitionsare a grouping mechanism. Swimlanes are the notation for partitions. They do not provide domain-specific semantics. Tools can generate swimlane presentation from domain-specific information without partitions. Register Bug Evaluate Impact Fix Bug Revise Plan Release Fix Test Fix [ priority = 1] Management Support Engineering
  • 78.
    Convenience Features Signalsend icon Signal … translates to a transition with a send action. Signal receipt icon … translates to a wait state (a state with no action and a signal trigger event). Coffee Pot Wake Up Get Cups Turn on Coffee Pot Coffee Done Drink Coffee Signal
  • 79.
    Case Study Adaptedfrom Kobryn, “UML 2001” Communications of the ACM October 1999 partition Submission Team Task Force Revision Task Force Issue RFP Evaluate initial submissions Submit specification draft Collaborate with competitive submitters Develop technology specification action state RFP [issued] [optional] control flow Finalize specification Specification [initial proposal] input value Begin object flow initial state join of control conditional fork fork of control Specification [final proposal]
  • 80.
    Case Study Adaptedfrom Kobryn, “UML 2001” Communications of the ACM October 1999 Evaluate initial submissions Evaluate final submissions Vote to recommend Enhance specification Implement specification Revise specification Finalize specification Specification [final proposal] Specification [adopted] Recommend revision Specification [revised] [NO] [YES] [else] [Enhanced] decision final state guard Collaborate with competitive submitters
  • 81.
    When to UseActivity Diagrams Use activity diagrams when the behavior you are modeling ... does not depend much on external events. mostly has steps that run to completion, rather than being interrupted by events. requires object/data flow between steps. is being constructed at a stage when you are more concerned with which activities happen, rather than which objects are responsible for them (except partitions possibly).
  • 82.
    Activity Diagram ModelingTips Control flow and object flow are not separate. Both are modeled with state transitions. Dashed object flow lines are also control flow. You can mix state machine and control/object flow constructs on the same diagram (though you probably do not want to).
  • 83.
    Activity Diagram ModelingTips From UML User Guide: Request Return Get Return Number Ship Item Item [returned] Receive Item Restock Item Credit Account Item [available] Customer Telesales Warehouse Accounting
  • 84.
    Activity Modeling TipsRequest Return Get Return Number Ship Item Item [returned] Receive Item Restock Item Credit Account Item [available] Customer Telesales Warehouse Accounting
  • 85.
    Activity Diagram ModelingTips Activity diagrams inherit from state machines the requirement for well-structured nesting of composite states. This means you should either model as if composite states were there by matching all forks/decisions with a correspond join/merges … … or check that the diagram can be translated to one that is well-nested. This insures that diagram is executable under state machine semantics.
  • 86.
    Activity Diagram ModelingTips Well-nested:
  • 87.
    Activity Diagram ModelingTips Not well-nested: Apply structured coding principles. (Be careful with goto’s!)
  • 88.
    Activity Diagram ModelingTips Can be translated to well-nested diagram on earlier slide:
  • 89.
    Wrap Up: ActivityDiagrams Use Activity Diagrams for applications that are primarily control and data-driven, like business modeling … … rather than event-driven applications like embedded systems. Activity diagrams are a kind of state machine until UML 2.0 … … so control and object/data flow do not have separate semantics. UML 1.3 has new features for business modeling that increase power and convenience. Check it out and give feedback!

Editor's Notes

  • #63 Slides will use abbreviations for simplicity. Sleight-of-hand will be explained next.
  • #64 Triggerless transitions is what makes activity graphs more useful for control and data flow. This is the sleight-of-hand mentioned on the previous slide.
  • #67 No standard notation yet for the name of an action, to indicate what kind of object and operation are being invoked. No standard notation for connecting an action state to the object it invokes an operation on. Likewise for the decomposition of a subactivity state into another state machine. The action state is polymorphic, the subactivity state is not.
  • #68 Make Deliver Mail polymorphic by using it as a method on an object. Can override the Deliver Mail Method with a new one on specializations of POEmployee. Not shown: use the top-level diagram (sorting and delivering mail) as a method, and make Put Mail In Boxes into an operation, then the entire application is polymorphic. The system is completely object-oriented when all steps are actions and all activity graphs are methods on an object.
  • #69 Concurrency expression is a set of lists of arguments, one list of arguments for one parallel invocation. No standard for how these are accessed. The UML Reference manual says they are passed as arguments to the current event (p 437). But the completion event is not actually created and queued.
  • #71 More about semantics of dashed line in pitfalls section. A step parameter refers to the parameters of the operations invoked by action states. Take Order and Fill Order can be subactivity states, whereupon the parameters are in the first/last action state in the subactivity graph, recursively.
  • #73 Use merge instead of dummy state before join.
  • #74 Synch state keep track at runtime of the difference in the number of times an incoming trigger has been traversed compared to an outgoing transition. It is Petri-like in this respect. This number can be bounded. An asterisk means no bound. In workflow systems these are called parallel synchronized or chained processes .
  • #77 Implementers of executing systems must take care that the join is aware that some or all the threads will not arrive. Modelers might want to attach a note to the join to remind readers of the same.
  • #79 Signal receipt is a natural way to model a wait state. Dashed line notation is specifically for use with the signal icons. Can you rotate icons when flow drawn horizontally?
  • #84 Diagram assumes that: 1) Receive Item and the OFS Item can be traversed in parallel. Same for Credit Account and Item OFS. 2) Restock item will not start until its Item input has arrived. 3) State machine can terminate with hanging Item OFS. These are natural assumptions for an object flow language, but UML is state machine based.
  • #87 Forks and joins are implicit composite states.