SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
UML REFERENCE CARD
© 1998 Allen I. Holub. All Rights Reserved.
Available from <http://www.holub.com>.
Static Model Diagrams
Packages
• C++ namespace.
• Group together functionally-similar classes.
• Derived classes need not be in the same package.
• Packages can nest. Outer packages are sometimes
called domains. (In the diagram, “Tools” is arguably
an outer package, not a domain).
• Package name is part of the class name (e.g. given the
class fred in the flintstone package, the fully-qualified
class name is flintstone.fred).
• Generally needed when entire static-model won’t fit
on one sheet.
Classes (Box contains three compartments)
1. The name compartment (required) contains the class
name and other documentation-related information:
E.g.:
Some_class «abstract»
{ author: George Jetson
modified: 10/6/2999
checked_out: y
}
• Guillemets identify stereotypes. E.g.: «static»,
«abstract» «JavaBean». Can use graphic instead of
word.
• Access privileges (see below) can precede name.
• Inner (nested) classes identify outer class as prefix
of class name: (Outer.Inner or Outer::Inner).
2. The attributes compartment (optional):
• During Analysis: identify the attributes (i.e. defin-
ing characteristics) of the object.
• During Design: identify a relationship to a stock
class.
This:
is a more compact (and less informative) version of
this:
Everything, here, is private. Always. Period.
3. The operations compartment (optional) contains
method definitions. Use implementation-language
syntax, except for access privileges:
• Abstract operations (C++ virtual, Java non-final)
indicated by italics (or underline).
• Boldface operation names are easier to read.
If attributes and operations are both omitted, a more com-
plete definition is assumed to be on another sheet.
1
Java, unfortunately, defaults to “package” access when no modifier is present. In my
“flavor” of UML, a missing access privilege means “public”.
Associations (relationships between classes)
• Associated classes are connected by lines.
• The relationship is identified, if necessary, with a < or
> to indicate direction (or use solid arrowheads).
• The role that a class plays in the relationship is identi-
fied on that class's side of the line.
• Stereotypes (like «friend») are appropriate.
• Unidirectional message flow can be indicated by an
arrow (but is implicit in situations where there is only
one role):
• Cardinality:
• Example:
class Company
{
private Employee[] peon = new Employee[n];
public void give_me_a_raise( Employee e ) { ... }
}
class Employee
{
private Company employer;
private Employee boss;
private Vector flunkies = new Vector();
public void you_re_fired() { ... }
}
(A Java Vector is a variable-length array. In this case it
will hold Employee objects)
Implementation Inheritance
Outline arrows identify derivation relationships: extends,
implements, is-a, has-properties-of, etc. Variations include:
Interface Inheritance
In C++, an interface is a class containing nothing but pure
virtual methods. Java supports them directly (c.f. “abstract
class,” which can contain method and field definitions in
addition to the abstract declarations.)
My extension to UML: rounded corners identify interfaces.
If the full interface specification is in some other diagram, I
use:
Strict UML uses the «interface» stereotype in the name
compartment of a standard class box:
Interfaces contain no attributes, so the attribute compart-
ment is always empty.
Java.awt
com.hulub
Application
Database
Interfaces
Oracle
Sybase
Tools
Class name
Attributes:
Operations:
+ public
# protected
- private
~ package (my extension to UML)1
Person
String name;
Person String
name
1 Usually omitted if 1:1
n Unknown at compile time, but bound.
0..1 (1..2 1..n)
1..* 1 or more
* 0 or more
1..* 1..*
relationship
A’s role in B B’s role in A
A B
Sender Receiver
Company
give_me_a_raise(Employee e)
Employee
you_re_fired()
1
employer peon
<works for 1..n
boss
1
1..* flunkies
SuperClass
- void concrete();
+ int override();
SubClass
+ int override();
+ int additional();
User
f() { x.operation() }
Iface Name
operation()
Implementer
operation()
relationship
x
User
Name
Implementer
InterfaceName
«interface»
Operations
Aggregation (comprises)
• Destroying the “whole” does not destroy the parts.
• Cardinality is allowed.
Composition (has) relationship
• The parts are destroyed along with the whole.
• Doesn’t really exist in Java.
• In C++:
class Container
{
Obj item1;
Obj *item2;
public:
Whole() { item2 = new Obj; }
~Whole(){ delete item2; }
};
Constraint
• A constrained relationship requires some rule to be
applied (e.g. {ordered}). Often combined with aggre-
gation, composition, etc.
• In the case of {or}, only one of the indicated relation-
ships will exist at any given moment (a C++ union, or
reference to a base class).
• {subset} does the obvious.
• In official UML, put arbitrary constraints that affect
more than one relationship in a “comment” box, as
shown. I usually leave out the box.
Qualified Association
• Hash tables, associative arrays, etc.
class User
{
// A Hashtable is an associative array, indexed
// by some key and containing some value.
private Hashtable bag = new HashTable();
private void add(String key, Item value) {
bag.put(key, value);
}
}
Association Class
• Use when a class is required to define a relationship.
• Somewhere, an additional relationship is required to
show ownership. (The one between person and Ticket
in the current example).
Dynamic-Model (Sequence) Diagrams
Objects and Messages (new style)
• Top boxes represent objects, not classes. You may
optionally add “:class” to the name if desired.
• Vertical lines represent the objects “life line”, or exist-
ence.
• Broken lifeline indicates the object is inactive, a rect-
angle indicates the object is active.
• represent messages being sent.
• (optional if synchronous) represent method
return. (May label arrow with name/type of returned
object).
• Sending object’s class must have:
1. An association of some sort with the receiving
objects class.
2. The receiver-side class’s “role” must be the same as
the name of the receiving object.
Object Creation
• The new instance appears at end of creation message
arrow.
• Destruction is accomplished by terminating the lifeline
with a large X:
Conditions
• Message sent only if conditional expression is true.
• The cond_expr is typically expressed in the imple-
mentation language.
Loops (extension to UML)
• Don’t think loops, think what the loop is accomplish-
ing.
• Typically, you need to send some set of messages to
every element in some collection. Do this with every.
• You can get more elaborate (every receiver where x<y)
• The diagram above comes from:
and maps to the following code:
class sender_class
{
receiver_class receiver[n];
public do_it() {
for(int i = 0; i < n; ++i)
receiver[i].message();
}
}
Arrow Styles for Messages
Asynchronous Callbacks
• Callback occurs while Sender is potentially executing
something else.
Part
Whole
Item
Container
role
Container
Item
Identity key()
{ordered}
role
Collection {or}
Container
Container
Comittee Person
{subset}
member-of *
*
*
1 chair-of
Comittee Comittee
{person.employer ==
Person.boss.employer}
0..1 *
boss peon
employee employer
* 0..1
User
add(String key,
Item value)
key Item
bag
Ticket
Person
Airline
Date when;
Seat where;
Airport to;
Airport from;
carrier passenger
<travels on
<buys
Sender Receiver
message()
message()
Sender
Receiver
new
Sender
Receiver
new
message()
Sender Receiver
[cond_expr] message()
Symbol Type Description
Simple Don’t care. Usually read as the
same as synchronous.
Synchronous Sender blocks until return.
Asynchronous Handler returns immediately and
both sender and receiver work
simultaneously.
Sender
Receiver
message()
Every
do_it()
sender_class
void do_it()
receiver_class
void message()
1 n
sender receiver
x
Sender Receiver
message()
callback()

Mais conteúdo relacionado

Semelhante a UML Reference Card.pdf

14_inheritance.ppt
14_inheritance.ppt14_inheritance.ppt
14_inheritance.ppt
sundas65
 
UML Diagram @ Software engineering discussion
UML Diagram @ Software engineering discussionUML Diagram @ Software engineering discussion
UML Diagram @ Software engineering discussion
CherryBerry2
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
lykado0dles
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
Getachew Ganfur
 

Semelhante a UML Reference Card.pdf (20)

Design patterns
Design patternsDesign patterns
Design patterns
 
14_inheritance.ppt
14_inheritance.ppt14_inheritance.ppt
14_inheritance.ppt
 
Claas diagram
Claas diagramClaas diagram
Claas diagram
 
Claas diagram
Claas diagramClaas diagram
Claas diagram
 
Principles of functional progrmming in scala
Principles of functional progrmming in scalaPrinciples of functional progrmming in scala
Principles of functional progrmming in scala
 
Programming in Java: Combining Objects
Programming in Java: Combining ObjectsProgramming in Java: Combining Objects
Programming in Java: Combining Objects
 
UML Diagram @ Software engineering discussion
UML Diagram @ Software engineering discussionUML Diagram @ Software engineering discussion
UML Diagram @ Software engineering discussion
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
 
Unified modeling language
Unified modeling languageUnified modeling language
Unified modeling language
 
Ooad lab manual
Ooad  lab manualOoad  lab manual
Ooad lab manual
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2
 
Class and object
Class and objectClass and object
Class and object
 
06 class diagrams
06 class diagrams06 class diagrams
06 class diagrams
 
Descriptions of class diagrams in software
Descriptions of class diagrams in softwareDescriptions of class diagrams in software
Descriptions of class diagrams in software
 
introofUML.pptx
introofUML.pptxintroofUML.pptx
introofUML.pptx
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
Design patterns with Kotlin
Design patterns with KotlinDesign patterns with Kotlin
Design patterns with Kotlin
 

Último

一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
F
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
F
 
一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书
A
 
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
AS
 
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
c6eb683559b3
 
Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...
Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...
Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...
mikehavy0
 
一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理
AS
 
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
AS
 
原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样
AS
 
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
Fir
 
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
AS
 
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
AS
 
如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证
如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证
如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证
hfkmxufye
 

Último (20)

Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
 
一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书
 
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
 
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
 
Washington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers ShirtWashington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers Shirt
 
[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon
[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon
[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon
 
APNIC Updates presented by Paul Wilson at CaribNOG 27
APNIC Updates presented by Paul Wilson at  CaribNOG 27APNIC Updates presented by Paul Wilson at  CaribNOG 27
APNIC Updates presented by Paul Wilson at CaribNOG 27
 
Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...
Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...
Abortion Clinic in Germiston +27791653574 WhatsApp Abortion Clinic Services i...
 
一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理
 
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
 
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
 
原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样
 
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
 
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
 
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
 
HUMANIZE YOUR BRAND - FREE E-WORKBOOK Download Now
HUMANIZE YOUR BRAND - FREE E-WORKBOOK Download NowHUMANIZE YOUR BRAND - FREE E-WORKBOOK Download Now
HUMANIZE YOUR BRAND - FREE E-WORKBOOK Download Now
 
Dan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat HoodieDan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat Hoodie
 
如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证
如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证
如何办理(UCLA毕业证)加州大学洛杉矶分校毕业证成绩单本科硕士学位证留信学历认证
 

UML Reference Card.pdf

  • 1. UML REFERENCE CARD © 1998 Allen I. Holub. All Rights Reserved. Available from <http://www.holub.com>. Static Model Diagrams Packages • C++ namespace. • Group together functionally-similar classes. • Derived classes need not be in the same package. • Packages can nest. Outer packages are sometimes called domains. (In the diagram, “Tools” is arguably an outer package, not a domain). • Package name is part of the class name (e.g. given the class fred in the flintstone package, the fully-qualified class name is flintstone.fred). • Generally needed when entire static-model won’t fit on one sheet. Classes (Box contains three compartments) 1. The name compartment (required) contains the class name and other documentation-related information: E.g.: Some_class «abstract» { author: George Jetson modified: 10/6/2999 checked_out: y } • Guillemets identify stereotypes. E.g.: «static», «abstract» «JavaBean». Can use graphic instead of word. • Access privileges (see below) can precede name. • Inner (nested) classes identify outer class as prefix of class name: (Outer.Inner or Outer::Inner). 2. The attributes compartment (optional): • During Analysis: identify the attributes (i.e. defin- ing characteristics) of the object. • During Design: identify a relationship to a stock class. This: is a more compact (and less informative) version of this: Everything, here, is private. Always. Period. 3. The operations compartment (optional) contains method definitions. Use implementation-language syntax, except for access privileges: • Abstract operations (C++ virtual, Java non-final) indicated by italics (or underline). • Boldface operation names are easier to read. If attributes and operations are both omitted, a more com- plete definition is assumed to be on another sheet. 1 Java, unfortunately, defaults to “package” access when no modifier is present. In my “flavor” of UML, a missing access privilege means “public”. Associations (relationships between classes) • Associated classes are connected by lines. • The relationship is identified, if necessary, with a < or > to indicate direction (or use solid arrowheads). • The role that a class plays in the relationship is identi- fied on that class's side of the line. • Stereotypes (like «friend») are appropriate. • Unidirectional message flow can be indicated by an arrow (but is implicit in situations where there is only one role): • Cardinality: • Example: class Company { private Employee[] peon = new Employee[n]; public void give_me_a_raise( Employee e ) { ... } } class Employee { private Company employer; private Employee boss; private Vector flunkies = new Vector(); public void you_re_fired() { ... } } (A Java Vector is a variable-length array. In this case it will hold Employee objects) Implementation Inheritance Outline arrows identify derivation relationships: extends, implements, is-a, has-properties-of, etc. Variations include: Interface Inheritance In C++, an interface is a class containing nothing but pure virtual methods. Java supports them directly (c.f. “abstract class,” which can contain method and field definitions in addition to the abstract declarations.) My extension to UML: rounded corners identify interfaces. If the full interface specification is in some other diagram, I use: Strict UML uses the «interface» stereotype in the name compartment of a standard class box: Interfaces contain no attributes, so the attribute compart- ment is always empty. Java.awt com.hulub Application Database Interfaces Oracle Sybase Tools Class name Attributes: Operations: + public # protected - private ~ package (my extension to UML)1 Person String name; Person String name 1 Usually omitted if 1:1 n Unknown at compile time, but bound. 0..1 (1..2 1..n) 1..* 1 or more * 0 or more 1..* 1..* relationship A’s role in B B’s role in A A B Sender Receiver Company give_me_a_raise(Employee e) Employee you_re_fired() 1 employer peon <works for 1..n boss 1 1..* flunkies SuperClass - void concrete(); + int override(); SubClass + int override(); + int additional(); User f() { x.operation() } Iface Name operation() Implementer operation() relationship x User Name Implementer InterfaceName «interface» Operations
  • 2. Aggregation (comprises) • Destroying the “whole” does not destroy the parts. • Cardinality is allowed. Composition (has) relationship • The parts are destroyed along with the whole. • Doesn’t really exist in Java. • In C++: class Container { Obj item1; Obj *item2; public: Whole() { item2 = new Obj; } ~Whole(){ delete item2; } }; Constraint • A constrained relationship requires some rule to be applied (e.g. {ordered}). Often combined with aggre- gation, composition, etc. • In the case of {or}, only one of the indicated relation- ships will exist at any given moment (a C++ union, or reference to a base class). • {subset} does the obvious. • In official UML, put arbitrary constraints that affect more than one relationship in a “comment” box, as shown. I usually leave out the box. Qualified Association • Hash tables, associative arrays, etc. class User { // A Hashtable is an associative array, indexed // by some key and containing some value. private Hashtable bag = new HashTable(); private void add(String key, Item value) { bag.put(key, value); } } Association Class • Use when a class is required to define a relationship. • Somewhere, an additional relationship is required to show ownership. (The one between person and Ticket in the current example). Dynamic-Model (Sequence) Diagrams Objects and Messages (new style) • Top boxes represent objects, not classes. You may optionally add “:class” to the name if desired. • Vertical lines represent the objects “life line”, or exist- ence. • Broken lifeline indicates the object is inactive, a rect- angle indicates the object is active. • represent messages being sent. • (optional if synchronous) represent method return. (May label arrow with name/type of returned object). • Sending object’s class must have: 1. An association of some sort with the receiving objects class. 2. The receiver-side class’s “role” must be the same as the name of the receiving object. Object Creation • The new instance appears at end of creation message arrow. • Destruction is accomplished by terminating the lifeline with a large X: Conditions • Message sent only if conditional expression is true. • The cond_expr is typically expressed in the imple- mentation language. Loops (extension to UML) • Don’t think loops, think what the loop is accomplish- ing. • Typically, you need to send some set of messages to every element in some collection. Do this with every. • You can get more elaborate (every receiver where x<y) • The diagram above comes from: and maps to the following code: class sender_class { receiver_class receiver[n]; public do_it() { for(int i = 0; i < n; ++i) receiver[i].message(); } } Arrow Styles for Messages Asynchronous Callbacks • Callback occurs while Sender is potentially executing something else. Part Whole Item Container role Container Item Identity key() {ordered} role Collection {or} Container Container Comittee Person {subset} member-of * * * 1 chair-of Comittee Comittee {person.employer == Person.boss.employer} 0..1 * boss peon employee employer * 0..1 User add(String key, Item value) key Item bag Ticket Person Airline Date when; Seat where; Airport to; Airport from; carrier passenger <travels on <buys Sender Receiver message() message() Sender Receiver new Sender Receiver new message() Sender Receiver [cond_expr] message() Symbol Type Description Simple Don’t care. Usually read as the same as synchronous. Synchronous Sender blocks until return. Asynchronous Handler returns immediately and both sender and receiver work simultaneously. Sender Receiver message() Every do_it() sender_class void do_it() receiver_class void message() 1 n sender receiver x Sender Receiver message() callback()