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...
![Page 1: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/1.jpg)
Introduction to UML
Lian YuDepartment of Computer Science and EngineeringArizona State UniversityTempe, AZ 85259
![Page 2: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/2.jpg)
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
![Page 3: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/3.jpg)
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
![Page 4: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/4.jpg)
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
![Page 5: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/6.jpg)
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
![Page 7: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/7.jpg)
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
![Page 8: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/8.jpg)
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
![Page 9: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/9.jpg)
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
![Page 10: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/10.jpg)
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
![Page 11: Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ 85259.](https://reader036.fdocuments.net/reader036/viewer/2022072011/56649e0f5503460f94af9e67/html5/thumbnails/11.jpg)
Tools to Draw UML Diagrams
Microsoft Visio Rational Rose