Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML...

55
Otzxuj{izout zu znk [tofikj Sujkrotm Rgtm{gmk .[SR/ Sgxzot Mumurrg [to|kxyozy ul Hxkskt2 Iusv{zkx Yioktik Jkvgxzsktz Jgzghgyk Yyyzksy Mxu{v2 nzzv@55}}}4jh4otluxsgzoq4{to3hxkskt4jk

Transcript of Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML...

Page 1: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

Introduction to theUnified Modeling Language (UML)

Martin GogollaUniversity of Bremen, Computer Science Department

Database Systems Group, http://www.db.informatik.uni-bremen.de

Page 2: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

1. Background

Page 3: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

1. Background 2

Informal Description of UMLExplanation 1 (Unified Modeling Language)• is a general purpose visual modeling language

• is designed to specify visualize, construct, and document theartifacts of software systems as well as for business modeling andother non-software systems

• is simple and powerful

• is based on a small number of core concepts that mostobject-oriented developers can easily learn and apply

• core concepts can be combined and extended so that expertobject modelers can define large and complex systems across awide range of domains

Page 4: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

1. Background 3

Explanation 2 (Primary goals in design of UML)• provide users a ready-to-use, expressive visual modeling language

so they can develop and exchange meaningful models

• provide extensibility and specialization mechanisms to extend thecore concepts

• be independent of particular programming languages anddevelopment processes

• provide a formal basis for understanding the modeling language

• encourage growth of OO tools market

• support higher-level development concepts such as collaborations,frameworks, patterns, and components

• integrate best practices

Page 5: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

1. Background 4

Explanation 3(Benefits of using UML for formal methods)• less time for explaining the notation

• document signatures and axioms with UML diagrams

• document the described system structure and behaviorwith UML diagrams

• think about formal specifications in a different language

• use Object Constraint Language OCL as a vehicle fortransporting other notations

Page 6: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

1. Background 5

Benefits of using UML for formal methods (cont’d)• tunable to special needs because it is a language

independent from a software process model

• speak the same language as people in industrialapplications (with the obvious danger that the twoparties talk about different things→ use only a minmalUML subset and explain the semantics)

• way of bringing formal methods and industrialapplications closer together

Page 7: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

1. Background 6

Development of UML

OOAD

OMT

OOSE

UMLSubmission

OMG

UMLStandard

UML’97

UML’98 UML’99 . . .

Page 8: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2. UML by Example

Page 9: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 8

2.1 Nine Diagram Formsfollowing the Notation Guide

• Static structure diagrams◦ (1) Class and (2) Object diagrams

• (3) Use case diagrams

• Interaction diagrams◦ (4) Sequence and (5) Collaboration diagrams

• (6) Statechart diagrams

• (7) Activity diagrams

• Implementation diagrams◦ (8) Component and (9) Deployment diagrams

Page 10: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 9

Use Case Diagram

Page 11: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 10

Class Diagram

Page 12: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 11

Object Diagram

Page 13: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 12

Sequence Diagram

Page 14: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 13

Collaboration Diagram

Page 15: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 14

Statechart Diagram

Page 16: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 15

Activity Diagram

Page 17: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 16

Component Diagram

Page 18: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.1 Nine Diagram Forms 17

Deployment Diagram

Page 19: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.2 TROLL light 18

2.2 TROLL light• intended to specify an information system as a

community existing and interacting objects

• intends to coherently describe structure and behaviourof objects

• incorporates ideas from semantic data models, processtheory, and abstract data types

• has set-theoretic semantics based on transitionsystems

• is supported by an animation system with web-baseduser interface

Page 20: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.2 TROLL light 19

Crossing System

South�North �

West

Eas

t

Page 21: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.2 TROLL light 20

TEMPLATE TrafficLightDATA TYPES Int, Bool;ATTRIBUTES Phase : int;

DERIVED Red, Yellow, Green : bool;EVENTS BIRTH createLight(initPhase:int);

switchLight;CONSTRAINTS 1<=Phase AND Phase<=3;VALUATION [createLight(initPhase)] Phase=initPhase;

[switchLight] Phase=(Phase MOD 3)+1;DERIVATION Red = (Phase=1);

Yellow = (Phase=3);Green = (Phase=2 OR Phase=3);

BEHAVIOR PROCESS TrafficLight =( createLight -> LightLife );

PROCESS LightLife =( switchLight -> LightLife );

END TEMPLATE

Page 22: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.2 TROLL light 21

TEMPLATE ControlDATA TYPES Int;TEMPLATES TrafficLight;SUBOBJECTS West, East, North, South : trafficLight;ATTRIBUTES Phase : int;EVENTS BIRTH createControl;

createLights;switchControl;

VALUATION [createControl] Phase=4;[switchControl] Phase=(Phase MOD 4)+1;

CONSTRAINTS 1<=Phase AND Phase<=4;West.Phase=East.Phase;North.Phase=South.Phase;West.Phase<>North.Phase;NOT(West.Green AND North.Green);NOT(West.Red AND North.Red);

Page 23: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.2 TROLL light 22

INTERACTION createLights >> West.createLight(3),East.createLight(3),North.createLight(1),South.createLight(1);

{Phase=4 OR Phase=2} switchControl >>West.switchLight,North.switchLight;

{Phase=1} switchControl >> North.switchLight;{Phase=3} switchControl >> West.switchLight;West.switchLight >> East.switchLight;North.switchLight >> South.switchLight;

BEHAVIOR PROCESS Control =(createControl -> CreateLights);

PROCESS CreateLights =(createLights -> ControlLife);

PROCESS ControlLife =(switchControl -> ControlLife);

END TEMPLATE

Page 24: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 23

2.3 UML Diagrams for TROLL light Example

To follow

• examples from crossing scenario for the nine diagramforms

• demonstrating UML diagram variety and emphasizingdifferent aspects

• description of general goal of respective diagram form

• quotations taken from UML Notation Guide

Page 25: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 24

Class Diagram for Object Types

1�

1

1�

1

1�

1

TrafficLight�Phase:int�/Red, /Yellow� , /Green:bool

createLight(initPhase:int)switchLight

Control

Phase:int�createControl�createLights�switchControl�

East� North� South�West�

1�

1

Page 26: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 25

Explanation 4 (Class diagrams)• show static structure of the model

• in particular, things that exist (such as classes andtypes), their internal structure, and their relationships toother things

• do not show temporal information

• although they may contain reified occurences of thingsthat have or things that describe temporal behavior

• are graphs of classifier elements connected by theirvarious static relationships

Page 27: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 26

Class Diagram for Data Types

+(i:int,j:int):int, mod(i:int,j:int):int, ...�-(i:int):int, abs(i:int):int, ...�

Bool�

false():bool, true():bool, ...�not(b:bool):bool, ...�and(b1:bool,b2:bool):bool, ...�

Int�

0():int, ...�succ(i:int):int, pred(i:int):int=(i:int,j:int):bool, <>(i:int,j:int):bool, ...�

Page 28: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 27

Class Diagram with Graphical Nesting for Composition

Control

West:TrafficLight

East:TrafficLight

North:TrafficLight

South:TrafficLight

1

1

1

1

Page 29: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 28

Object Diagram

West:TrafficLight

/Red=false/Yellow=false/Green=true

South:TrafficLight

/Red=true/Yellow=false/Green=false

East:TrafficLight

/Red=false/Yellow=false/Green=true

:Control�

North:TrafficLight

/Red=true/Yellow=false/Green=false

Page 30: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 29

Explanation 5 (Object diagrams)• show instances compatible with a particular classdiagram

• are graphs of instances, including objects and datavalues

• are instances of a class diagram (see Expl. 3)

• show a snapshot of detailed state of a system at apoint in time

Page 31: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 30

Use Case Diagram

generate traffic lights

switch traffic control

generate control

Engineer

Operator

Crossing�

Page 32: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 31

Explanation 6 (Use case diagrams)• show relationship among actors and use cases within a system

• represent functionality of a system or a class as manifested toexternal interactors

• are graph of actors, a set of use cases enclosed by a systemboundary, communication (participation) associations betweenactors and use cases, and generalizations among use cases

• show coherent units of functionality provided by a system or classas manifested by sequences of messages exchanged among thesystem and one or more outside interactors (called actors)together with actions performed by the system

Page 33: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 32

Sequence Diagram

����� ����� ����������

����� ��������� � ��� !�"�# $�%�&�'�# ( &�$ )�*�+ ,�-�.0/1+ 2 .�, 354 6 7�8�9�:�6 ; 9�7

<�=�> ?�@A�B CD�?�E�C�F

G�H�I J�K�L�M�I N L�J O�P�Q R�S�T�U�Q V T�R

W�X�Y Z�[\�] ^_�Z�`�^�a

b�c�d e�f�g�h�d i g�e j�k�l m�n�o�p�l q o�m r�s�t u�v�w0x1t y w�u z5{ | }�~�����| � ��}

����� ������ ����������

����� �����0�1� � ��� �5� � ��������� � ���

�����  �¡�¢�£�� ¤ ¢�  ¥�¦�§ ¨�©�ª�«�§ ¬ ª�¨ ­�®�¯ °�±�²0³1¯ ´ ²�° µ5¶ · ¸�¹�º�»�· ¼ º�¸

½�¾�¿ À�ÁÂ�à ÄÅ�À�Æ�Ä�Ç

ÈÊÉ�Ë�ÌÎÍ�Ï�Ë�Ð

ÑÓÒÔ�Õ Ö�×�ØÚÙ�Û ÜÓÝ�Þ�ß�àáãâåä�æ

ç�è�éëêåì�éëí�î�ï�ì�è�îð

ñ�ò�óåôëõ�ó�ö1÷ ø ù�õûúüý�þëÿ���þ���� ����� ���

��������������� ������ �"! #�$�%�&�'�%�(�) *�+'�,.-0/

1�2�3�4�5�3�6�7 8�95�:.;0<

Page 34: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 33

Sequence Diagram Part 1

����������� ������ ������������ ������� �������! #"%$&�(')"*� +�,�-�.�/0�1 -�2�0*.

3�4�5�6�7#8 9;:=<>6@?A:�B

CED;F=G�H@IAF)J

KML NPO QSR�TVU@W XZY�[�\@]^ _a`cb

deAfag&h�fji;k�l�h@eAk�m

n#oAprq&s�p=t u�v�w�s�xyzA{a|&}�{�~&�����*}���� �

��A�a�&�����&�(�)�*�����a� ��A�a�&�����&�(�)�*�����c�

 ¡A¢a£&¤�¢�¥&¦(§)¨*¤�©�ªc«

Page 35: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 34

Sequence Diagram Part 2

����������� �

������� ��������� � ��!#"$% &('*)

+-,�.0/213.54�6�7�1�,�6�8

9;:�<0=2>?<A@(BDC�E#>�FG;H�I0J2K3I�L(MDN OPKRQRS�T

U-V�W0XZY?W�[(\D] ^PY_R`(a b-c�d0e2f3d�g(hDi jPfkmlon

p-q�r0s2t3r�u(vDw xPtymzo{

|~}����?�;�Z�������������

�~�����?�;���(�D� �P� �������3�-�5�Z�����#�

���� �¡?¢;£(¤�¥ ¦P¡§�¥ ¨

©�ª�«�¬3­-®5¯Z«�°�®#¬ ±�²�³�´3µ-¶5·Z³�¸�¶#´ ¹�º�»�¼?½;¾�¿(»DÀ ¾P¼ Á~Â�Ã�Ä?Å;Æ�Ç(ÃDÈ ÆPÄ

Page 36: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 35

Sequence Diagram Part 3

�������������

������ �������� �������! " #%$'&

(*)�+%,.-/+10�2�3�-)�2�4

5*6�7%8.9/7;:.<>=�?@9�AB*C�D%E.F/D;G.HJILK@FNMNO%P

Q*R�SUTWV/S;X�Y>ZL[@VN\N]%^ _*`�a%b.c/a;d.eJfLg@cNhji'k

l*m�n%o.p/n;q.rJsLt@pNujv'w

xzy|{~}/�*��������}�����

�z�|�~�/�*���.�J�L�@� �z�|�~�/�*���.�J�L�@� ���|���/�*� ���>¡���� ¢z£|¤~¥§¦©¨�ª�¤>«L¨@¥

¬z­|®~¯/°*±�²�³�´�¯µ�³�¶

·z¸|¹~º/»*¼�½.¹J¾L¼@º ¿zÀ|Á~Â/Ã*Ä�Å.ÁJÆLÄ@Â

Page 37: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 36

Explanation 7 (Sequence diagrams)• show a pattern of interaction among objects

• show an interaction arranged in time sequence

• show objects participating in interaction by theirlifelines and messages that they exchange arranged intime sequence

• do not show associations among objects

• can exist in a generic form (describe all possbilesequences) and in an instance form (describe oneactual sequence constistent with the generic form);without loops or branches, the two forms are isomorphic

Page 38: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 37

Collaboration Diagram

East� North� South�West�

3a : switchLight�

7a : switchLight�6a : switchLight�5a : switchLight�

2a : createLight(3)�3b : switchLight�

7b : switchLight�6b : switchLight�5b : switchLight�

2b : createLight(3)�3c : switchLight�

7c : switchLight�

5c : switchLight�4a : switchLight�

2c : createLight(1)�3d : switchLight�

7d : switchLight�

5d : switchLight�4b : switchLight�

2d : createLight(1)�

:Control

3 : switchControl

7 : switchControl�6 : switchControl5 : switchControl4 : switchControl

1 : createControl�2 : createLights�

Page 39: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 38

Explanation 8 (Collaboration diagrams)• show a pattern of interaction among objects

• show an interaction organized around the objects inthe interaction and their links to each other

• show relationships among object roles

• do not show time as a separate dimension, sosequence of messages and concurrent threads must bedetermined using sequence numbers

• represent a collaboration, which is a set of objectsrelated in a particular context, and an interaction, whichis a set of messages exchanged among objects within acollaboration to effect a desired operation or result

Page 40: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 39

Sequence diagramsversus

Collaboration diagrams

• Sequence diagrams and collaboration diagramsexpress similar information but show it in different ways

• Sequence diagrams show explicit sequence ofmessages and are better for real-time specificationsand for complex scenarios

• Collaboration diagrams show relationships amongobjects and are better for understanding all of effects ona given object and for procedural design

Page 41: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 40

Statechart Diagram for B EHAVIOR Sections

TrafficLight�createLight�

LightLife� switchLight

Control� CreateLights�createControl� createLights�

ControlLife switchControl�

TrafficLightBehavior�

ControlBehavior�

Page 42: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 41

Explanation 9 (Statechart diagrams)• show sequences of states that an object or aninteraction goes through during its life in response toreceived stimuli, together with its responses and actions

• show graphs of states and transitions that describeresponse of an object of a given class to receipt ofoutside stimuli

• are attached to a class or a method

• show states represented by state symbols andtransitions represented by arrows connecting statesymbols

• may contain subdiagrams by physical containment

Page 43: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 42

Statechart Diagram for LightLife

switchLightswitchLight

Red�Phase=1�

Green�

Phase=2�GreenYellow

Phase=3�

switchLight�LightLife�

[initPhaseEqualTo(1)] [initPhaseEqualTo(3)]

Page 44: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 43

Statechart Diagram for ControlLife

ControlLife

switchControl�

West.Phase=2 [G]�

Phase=3�

switchControl�

switchControl�

West.Phase=1 [R]�

Phase=1�

West.Phase=1 [R]�

Phase=2�

West.Phase=3 [GY]�

Phase=4�

switchControl�

North.Phase=2 [G]� North.Phase=3 [GY] North.Phase=1 [R]� North.Phase=1 [R]�

Page 45: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 44

Statechart Diagram with Concurrent Substates

TrafficLight/West

CreateLights

TrafficLight/North

[Control.P=2]switchLight

[Control.P=4]switchLight [Control.P=1]switchLight

switchControl switchControl switchControl

switchControl

[Control.P=2]switchLight

[Control.P=4]switchLight

P=1 P=2 P=3

P=4P=3P=2P=1

P=1 P=2 P=3

[Control.P=3]switchLight

Control

createControl

createLight

createLight

createLights

Page 46: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 45

Statechart Diagrams with Messages Sent

ControlLife

switchControl�

West.Phase=2 [G]�

Phase=3�

switchControl�

switchControl�

West.Phase=1 [R]�

Phase=1�

West.Phase=1 [R]�

Phase=2�

West.Phase=3 [GY]�

Phase=4�

switchControl�

North.Phase=2 [G]� North.Phase=3 [GY] North.Phase=1 [R]� North.Phase=1 [R]�

switchLightswitchLight

Red�Phase=1�

Green�Phase=2�

GreenYellowPhase=3�

switchLight�LightLifeNorthSouth

switchLightswitchLight

Red�Phase=1�

Green�Phase=2�

GreenYellowPhase=3�

switchLight�LightLifeW� estEast

Page 47: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 46

Activity Diagram for Derivation Rules

eval[Phase=1]�

eval[Phase=2 or Phase=3]�

read(Phase)�

write(Red)� write(Yellow) write(Green)�

eval[Phase=3]

Page 48: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 47

Explanation 10 (Activity diagrams)• are variations of state machines in which states are activitiesrepresenting performance of operations and the transitions aretriggered by completion of operations

• represent a state machine of a procedure itself; the procedure isthe implementation of an operation on owning class

• are special cases of state diagrams in which all (or at least most)of states are action states and in which all (or at least most) oftransitions are triggered by completion of actions in the sourcestates

• are attached to a class or to implementation of an operation or ause case

• focus on flows driven by internal processing (as opposed toexternal events)

Page 49: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 48

Activity diagramsversus

Statechart diagrams

• Use activity diagrams in situations where all or most ofthe events represent completion of internally-generatedactions (that is, procedural flow of control)

• Use ordinary state diagrams in situations whereasynchronous events occur

Page 50: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 49

Activity Diagram for Triggering andValuation of Phase=initPhase

initPhase

write-attribute�

PhaseWritten

expr-value

eval-expr

TrafficLight� Temporary�Control

createLight(c)�createLights�

Page 51: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 50

Component Diagram

Bool�Int

DataTypeInterface�

TrafficLight� Control�

Page 52: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 51

Explanation 11 (Component Diagrams)• show structure of the code itself

• show dependencies among software components,including source code components, binary codecomponents, and executable components

• have only a type form, not an instance form

• are graphs of components connected by dependencyrelationships

• may also be used to show interfaces and callingdependencies among components

Page 53: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 52

Deployment DiagramWestNorth:PC�

West:Traf� ficLight North:Traf� ficLight

EastSouth:PC�

East:Traf� ficLight

South:Traf� ficLight

MainServer:SUN

Root:Control�

DataTypeHandler�

Page 54: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 53

Explanation 12 (Deployment Diagrams)• show configuration of run-time processing elementsand the software components, processes, and objectsthat live on them

• show structure of run-time system

• are graphs of nodes connected by communicationassociations

Page 55: Introduction to the Unified Modeling Language€¦ · 1. Background 2 Informal Description of UML Explanation 1 (Unified Modeling Language) is a general purpose visual modeling language

2.3 UML Diagrams for TROLL light Example 54

Relationship between UML Diagram Forms

StaticStructure�

UseCase�

Object�Class�

Implementation�

Component� Deployment�

Requirements� Analysis and Design� Implementation�

Behavioral

Interaction�

Sequence Collaboration

Statechart�

Activity

OCL�

Emphasis on�"schema/type" aspect

Emphasis on�"instance" aspect