Professional Documents
Culture Documents
UML Design Basics
UML Design Basics
bus
models
vehicle
car
models
cup
models
UML Diagrams
Major Concepts
Specification of software design and code
through:
Class diagrams
Object diagrams
Sequence diagrams
Collaboration diagrams
Class Notation
Class
Name
Attributes
Operations
Attributes - Signature
[visibility] name [[multiplicity]] [: type] [=initial value] [{property}]
Multiplicity
Objects on both sides of the Indicates cardinality
default
association can find each 3 exactly 3 object
other * (or n) - unbounded
1..* - 1 to eternity
The relation is consistent in 3..9 3 to 9
time (unless removed)
Association Example
public class Person {
private Dog pet;
}
public class Dog {
private Person owner;
}
public class PetCentre {
public Dog[] availableDogs;
}
Navigation
Folder File
Given a folder, we want to
know the files of each
folder.
However, we do not have a
requirement for knowing the
folder of each file.
Links should be
verified,
according to the
association
multiplicity
For each link, an
association class
instance should
be declared
Attribute or association?
Attribute
Value is important, not identity: Date, Number,
String
Little behavior and functionality
1
2
3
Before After
Dependency
Notated by a dotted line
The most general relation between classes
Indicates that an object affects another object
AccountingSystem
creates a Receipt
object
Dependency
Dependencies are the most abstract type of
relations.
Dependencies are always directed
Types:
call
create
MailClient-MailServer Relation
Aggregation
Whole-
Assemble a class from other classes
- assemble a class from a
couple of instances of that class
Aggregation (2)
Worker * *..1 *
Person Company
employee employer
1..0
Manages Manager
Four Different Representations
for Class Diagram
In runtime
Class
Object
Java code:
ListOfThings<BlogEntry> listofBlogEntries;
Association Classes
Denoted as a class attached to the association, and
specify properties of the association
According to the
An association class requirements, each
product can appear is
several orders, and
each order may include
several products
Association Class - Objects
Links should be
verified,
according to the
association
multiplicity
For each link, an
association class
instance should
be declared
Identifying Classes:
True Purpose of Object Diagrams
Motivating Scenario
The Corresponding Object
Diagram
The Corresponding Class
Diagram
Refinement to Class Diagram
Major Concepts
Specification of software design and code
through:
Class diagrams
Object diagrams
Sequence diagrams
Collaboration diagrams
Notations for
Sequence Diagram
Message Signature
Message signature
attribute = signal_or_message_name (arguments) : return_type
Examples:
doSomething()
doSomething(number1 : Number, number2 : Number)
doSomething() : ReturnClass
myVar = doSomething() : ReturnClass
Nested Messages
Message Arrows
Sample Sequence Diagram
Corresponding Java Code
public class MailServer
{
1 public MailItem getNextMailItem(String who)
{
1.1 Iterator<MailItem> it = items.iterator();
loop while(it.hasNext()) {
1.2 MailItem item = it.next();
opt if(item.getTo().equals(who)) {
1.3 it.remove();
1.4 return item;
}
}
1.4 return null; Correspondence with
} numbers in sequence
diagram
Major Concepts
Specification of software design and code
through:
Class diagrams
Object diagrams
Sequence diagrams
Collaboration diagrams
Sample Sequence Diagram
Equivalent Communication
Diagram
Note:
Sample Communication
Diagram