Introduction To Unified Modeling Language (UML)
Introduction To Unified Modeling Language (UML)
Language (UML)
6-2
UML
6-3
UML is a Modeling Language
UML
graphical notation to describe software design
has rules on how to draw models of
classes
associations between classes
message sends between objects
has become the de facto industry standard
Not official, but everyone uses it
Like a blueprint to show what is going on during analysis,
design and implementation
Some Projects require UML documentation
6-4
UML Defined by the Authors
The Unified Modeling Language User Guide,
Booch, Rumbaugh, Jacobson states:
The UML is a language for
visualizing
specifying
constructing
documenting
the artifacts of a software intensive system
6-5
First up: Class Diagrams
A class diagram
expresses class definitions to be implemented
lists name, attributes, and methods for each class
shows how instances will connect to one others
UML allows different levels of detail on both
the attributes and the methods of one class
could be just the the class name in a rectangle
or like the general form shown on the next slide
6-6
Software Specification (Class Name)
attribute
attribute : type
attribute : type = initial value
classAttribute
derivedAttribute
...
method1()
method2(parameter : Type) : return type
abstractMethod()
+publicMethod()
-privateMethod()
#protectedMethod()
classMethod()
...
6-7
AccountCollection
- allAccounts : HashMap
+AccountCollection ()
+getAccountWithID (ID: String) : Account
+add(accountToAdd: Account) : boolean
+iterator() : Iterator
6-8
Sterotypes
6-9
Different levels of detail
6-10
Relationships
6-11
1) Dependency: A Uses Relationship
Dependencies
occurs when one object depends on another
if you change one object's interface, you need to
change the dependent object
arrow points from dependent to needed objects
CardReader
Jukebox
CDCollection
SongSelector
6-12
2)Association: Structural Relationship
Association
a relationship between classes indicates some
meaningful and interesting connection
Can label associations with a hyphen connected
verb phrase which reads well between concepts
association
getAccountWithID
Jukebox JukeboxAccountCollection
1 1
6-13
Associations
Associations imply
our knowledge that a relationship must be
preserved for some time (1 ms to forever)
Between what objects do we need to remember a
relationship?
• Does a Transaction need to remember Account?
• Would AccountCollection need to remember
Accounts?
Stores
AccountCollection Account
1 1..*
6-14
Notation and Multiplicity Adornments
UML Association:
a line between two concepts and a name
they are bi-directional * T
zero or more;
"many"
can have a multiplicity
exist in class diagrams 1..*
T one or more
1..52
T one to fifty two
5
Multiplicity T exactly five
adornments
3, 5, 8 exactly three,
T
five or eight
6-15
Multiplicity
Mother Child
1 1+
Car Wheel
1 4
Car Wheel
1 5
Car Wheel
1 3
6-17
Association Names Upcase / hyphenate
Read this Type-VerbPhrase-Type (POST is a Point of Sale Terminal)
Store
1
Contains
1.. *
POST Captures Sale Paid-by Payment
1 1.. * 1 1
Not yet worrying about messages, instance variables, data flow,
or classes yet
Just shows which objects have associations
Airline
6-18
1
Aggregation: A Special Association
6-19
Composition: A Special Association
Composition: Stronger relationship
One can not exist without the other
If the school folds, students live on
but the departments go away also
If a department closes, the school can go on AIC e.g.
School Department
1 1..*
1..*
6-20
Sequence Diagrams
6-21
Sequence Diagrams
6-22
http://www.ifi.uio.no/in219/verktoy/doc/html/doc/user/mg/dgmsuml6.htm
l
6-23
http://www.visual-paradigm.com/
VPGallery/diagrams/Sequence.html
6-24