unified modeling language (uml) - virginia techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · unified...

8
Unified Modeling Language (UML)

Upload: others

Post on 15-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Unified Modeling Language

(UML)

Page 2: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

UML

• Graphical notation to support expressing Object-Oriented Designs in a compact form• Notation is quite expressive, includes many different

types of diagrams, and can be used to generate code

• We will use Class diagrams from UML• Capture a high level description of a class as well as

the relationships with other classes.

Page 3: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Simple text notation

• The UML diagrams have a simple text notation to indicate visibility.

• Consider a class with a member variable of type String called “name”

Notation Meaning Example

- private - name : String

+ public + name : String orname : String

# protected # name : String

Page 4: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Graphical Notations

• Class diagram• Name on top, usually

bolded• Attributes are member vars• Operations are methods

• Interface diagram• Adds the stereotype

designation <<interface>>

Page 5: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Inheritance

• Inheritance relates two classes

• One class is defined as an extension of the other• Existing one is called: base

class, superclass• New class called: subclass,

or derived class

• Connected in diagram with arrow with white triangle

Page 6: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Aggregation

• One class is made up of others (aggregation of objects)

• BigClass is defined in terms of other classes• Some of member vars are

objects of another class

Page 7: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Association

• Relationship between objects• Different from aggregation

because objects are considered “complete”whether the association is in place or not.

• Example: student object has an association with several course sections, the ones that she is registered in.

• Can have cardinality

Page 8: Unified Modeling Language (UML) - Virginia Techcourses.cs.vt.edu/~cs1706/notes/uml.pdf · Unified Modeling Language (UML) Created Date: 10/18/2004 11:45:26 AM

Association

• Sometimes the association is an object by itself

• Often when the association holds data

• Example: employment associates Person with Company, includes information about employment date, position title, etc.