UML Part 3 UML 2 Wolfgang Pelz 2000

  • Slides: 21
Download presentation
UML Part 3 UML 2 © Wolfgang Pelz 2000 -04 1

UML Part 3 UML 2 © Wolfgang Pelz 2000 -04 1

Chapter Ten State Machine Diagrams UML 2 © Wolfgang Pelz 2000 -04 2

Chapter Ten State Machine Diagrams UML 2 © Wolfgang Pelz 2000 -04 2

State Machine Diagrams • capture the lifecycle and behavior of objects, subsystems, or systems

State Machine Diagrams • capture the lifecycle and behavior of objects, subsystems, or systems • specify the sequence of states an object goes into, based on responses to events, and actions the object may perform UML 2 © Wolfgang Pelz 2000 -04 3

Terminology • state - condition or situation in the life of an object determined

Terminology • state - condition or situation in the life of an object determined by attributes • transition - movement from one state to another • event/trigger - an external stimulus that may cause a transition • action - some activity that results in a change of state or a return value UML 2 © Wolfgang Pelz 2000 -04 4

Thanking Turning a computer on: states? transition? event? actions? UML 2 © Wolfgang Pelz

Thanking Turning a computer on: states? transition? event? actions? UML 2 © Wolfgang Pelz 2000 -04 5

Notation UML 2 © Wolfgang Pelz 2000 -04 6

Notation UML 2 © Wolfgang Pelz 2000 -04 6

Example State Diagram Actions: “go up”, “go down”, “arrived”, … State: “On first floor”,

Example State Diagram Actions: “go up”, “go down”, “arrived”, … State: “On first floor”, Moving up”, “Idle”, … UML 2 © Wolfgang Pelz 2000 -04 7

Messages between State Diagrams UML 2 © Wolfgang Pelz 2000 -04 8

Messages between State Diagrams UML 2 © Wolfgang Pelz 2000 -04 8

and-substate (concurrency) UML 2 © Wolfgang Pelz 2000 -04 9

and-substate (concurrency) UML 2 © Wolfgang Pelz 2000 -04 9

Sequential Substates UML 2 © Wolfgang Pelz 2000 -04 10

Sequential Substates UML 2 © Wolfgang Pelz 2000 -04 10

Activity Diagram • captures actions and their results • variation of state diagram, but

Activity Diagram • captures actions and their results • variation of state diagram, but emphasizing actions • actions: work and activities to be performed • results: object-state changes (not the major point) • actions may be placed in swimlanes UML 2 © Wolfgang Pelz 2000 -04 11

Activity Diagram (cont. ) includes: • how actions are taken • what they do

Activity Diagram (cont. ) includes: • how actions are taken • what they do (activities) • when they take place (action sequence) • where they take place (swimlanes) UML 2 © Wolfgang Pelz 2000 -04 12

Example of a Printing Program UML 2 © Wolfgang Pelz 2000 -04 13

Example of a Printing Program UML 2 © Wolfgang Pelz 2000 -04 13

Another way. . . UML 2 © Wolfgang Pelz 2000 -04 14

Another way. . . UML 2 © Wolfgang Pelz 2000 -04 14

Decision Point UML 2 © Wolfgang Pelz 2000 -04 15

Decision Point UML 2 © Wolfgang Pelz 2000 -04 15

Forks and Joins • • concurrent or parallel flow of control synchronization bar #

Forks and Joins • • concurrent or parallel flow of control synchronization bar # of forks matches # of joins activities in parallel flows may use signals to communicate (such communicating sequential processes are called co-routines) UML 2 © Wolfgang Pelz 2000 -04 16

Example UML 2 © Wolfgang Pelz 2000 -04 17

Example UML 2 © Wolfgang Pelz 2000 -04 17

Swimlanes (in Activity Diagrams) • group activities with respect to their responsibilities • useful

Swimlanes (in Activity Diagrams) • group activities with respect to their responsibilities • useful when modeling workflows of business processes • specify loci of activities • every activity belongs to exactly one swimlane, but transitions may cross lanes UML 2 © Wolfgang Pelz 2000 -04 18

Example UML 2 © Wolfgang Pelz 2000 -04 19

Example UML 2 © Wolfgang Pelz 2000 -04 19

Use an activity diagram when • analyzing a use case • understanding workflow across

Use an activity diagram when • analyzing a use case • understanding workflow across many use cases • multi-threaded applications • capturing the work to be performed as an operation is executing UML 2 © Wolfgang Pelz 2000 -04 20

Don’t use when. . . • trying to see how objects collaborate (collaborative actions

Don’t use when. . . • trying to see how objects collaborate (collaborative actions instead of individual activities); use an interaction diagram instead • trying to see how an object behaves over its lifetime; use a state diagram instead • modeling a scenario; instead attach it to the appropriate use case UML 2 © Wolfgang Pelz 2000 -04 21