Basics of UML Diagrams With Examples
Basics of UML Diagrams With Examples
Suggested reading: Practical UML: A hands on introduction for developers http://dn.codegear.com/article/31863 UML Distilled Ch. 3, by M. Fowler
1
Example architectures
person
sea agent
VerizonWireless
UW student
lake agent
GPS satellite
amphibious agent
Cell phone
Big questions
What is UML?
Why should I bother? Do people really use UML?
Design phase
design: specifying the structure of how a software system will be written and function, without actually writing the complete implementation a transition from "what" the system must do, to "how" the system will do it
What classes will we need to implement a system that meets our requirements? What fields and methods will each class have? How will the classes interact with each other?
UML diagrams
class diagrams (today) sequence diagrams ...
What is UML?
UML: pictures of an OO system
programming languages are not abstract enough for OO design UML is an open standard; lots of companies use it
as a programming language: with the right tools, code can be auto-generated and executed from UML
only good if this is faster than coding in a "real" language
UML
In an effort to promote Object Oriented designs, three leading object oriented programming researchers joined ranks to combine their languages:
Grady Booch (BOOCH) Jim Rumbaugh (OML: object modeling technique) Ivar Jacobsen (OOSE: object oriented software eng) and come up with an industry standard [mid 1990s].
Very big, but a nice standard that has been embraced by the industry.
attributes (optional)
should include all fields of the object
Comments
represented as a folded note, attached to the appropriate class/method/etc by a dashed line
class: solid line, black arrow abstract class: solid line, white arrow interface: dashed line, white arrow
often omit trivial / obvious generalization relationships, such as drawing the Object class as a parent
Associational relationships
associational (usage) relationships
1. multiplicity
* 1 2..4 3..*
2. name 3. navigability
Multiplicity of associations
one-to-one
each student must carry exactly one ID card
one-to-many
one rectangle list can contain many rectangles
Car
Association types
aggregation: is part of
symbolized by a clear white diamond
1 1
Engine
aggregation
Book
1 *
Page
Lottery Ticket
Random
Composition/aggregation example
If the movie theater goes away so does the box office => composition but movies may still exist => aggregation
26
Simple Aggregation
Rental Invoice
1..* 1
Composition
0..1
Simple Association
Generalization
100
Student
- firstName : String - lastName : String - homeAddress : Address - schoolAddress : Address + toString() toString() : String
Address
- streetAddress : String - city : String - state : String - zipCode : long + toString() : String
Rational Rose
http://www.rational.com/
What classes are in this system? What are their responsibilities? Which classes collaborate? Draw a class diagram for this system. Include relationships between classes (generalization and associational).