Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University...
-
Upload
jasper-hodges -
Category
Documents
-
view
212 -
download
0
Transcript of Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University...
Introduction to UML
Lian YuDepartment of Computer Science and EngineeringArizona State UniversityTempe, AZ 85259
UML, UML Diagrams
UML stands for the Unified Modeling Language
UML diagrams show/visualize relationships among classes and objects
Several types of UML diagrams exist, each designed to show specific aspects of object-oriented program design
Class Diagram
A UML class diagram consists of one or more classes, each with sections for the class name, attributes, and methods
Depending on the goal of the diagram, the attribute and/or methods sections can be left out of any class
Lines between classes represent associations
Associations/aggregation can show multiplicity
Class Diagram
Attributes and methods may be marked as: Private, indicating they are not visible to callers outside
the class Protected, they are only visible to children of the class Public, they are visible to all
Symbol Meaning
+
-
#
Public
Private
Protected
UML Class Diagrams
A UML class diagram for the FlipRace program:
FlipRace
main (args : String[]) : void
Coin
face : int
flip() : voidisHeads() : booleantoString() : String
1 2
Object Diagram
A UML object diagram consists of one or more instantiated objects.
It is a snapshot of the objects during an executing program, showing data values
coin1 : Coin
face = 0
coin2 : Coin
face = 1
Association in UML
Two classes having a general associationThose classes are “aware” of each
otherObjects of those classes may use
each other for the specific servicesThis sometimes is referred to as a use
relationship
Association
When a class participates in an association, it has a specific role that it plays in that relationship
A role is just the face the class at the near end of the association presents to the class at the other end of the association.
Person Company+employer+emplyee
association
role name
Aggregation in UML
An aggregate object is an object that contains references to other objects
For example, an Account object contains a reference to a String object (the owner's name)
An aggregate object represents a has-a relationship
A bank account has a name Likewise, a student may have one or more
addresses
Aggregation in UML
An aggregation association is shown in a UML class diagram using an open diamond at the aggregate end
StudentBody
+ main (args : String[]) : void
+ toString() : String
1 2Student- firstName : String
- lastName : String- homeAddress : Address- schoolAddress : Address
+ toString() : String
- streetAddress : String- city : String- state : String- zipCode : long
Address
Tools to Draw UML Diagrams
Microsoft Visio Rational Rose