UML Class Diagram - ayaohsu/Personal-Resources GitHub Wiki
Unified Modeling Language
Development Process
- Waterfall
- Analysis, Design, Coding and Testing
- Interactive
Class Diagram
Format
- A class is drawn as a rectangle split into up to three sections
- name of the class
- attributes
- operations
- attributes: represent the state of an object
- inline attribute: [visibility symbol] [name]: [type]
- associated attribute
- visibility symbol
+
: public, -
: private, #
: protected
Relationships
- (Strongest) Inheritance, Composition, Aggregation, Association, Dependency (Weakest)
- Dependency (<--- dashed arrow)
- Definition: When objects of one class work briefly with objects of another class\
- Example: The web
UserInterface
depends on the BlogEntry
(can have the function renderBlogEntry(BlogEntry entry)
)
- Association (____ simple connecting line)
- Definition: when objects of one class work with objects of another class for some prolonged amount of time
- Example: The
BlogAccount
is associated with zero or more BlogEntry
s
- Aggregation(<>____ empty diamond arrow)
- Definition: when one class owns but shares a reference to objects of another class
- Example: An author owns but may share one or many
BlogAccount
s with other authors
- Composition (<|>____ filled diamond arrow)
- Definition: when one class contains object of another class
- Example: A
BlogAccount
is made up of an Introduction
and a MainBody
- You are modeling the internal parts that make up a class
- Inheritance (<|____ empty arrow), or generalization
- Definition: When one class is a type of another class
- A
BlogEntry
and a WikiPage
are both types of Article
- Good rule of thumb to use generalization is to used only when a class really is a more specialized type of another class and not just as a convenience to support reuse
- Association name (|> filled arrow)
- Optional; more detailed description about the association relationships
- Example:
Professor
writes the Book
s; "write" can be presented as the association name near the association path
- There can be more than one relationship between two classes. Use this to represent the different relationships
Employee
___ Address
: permanent address or temporary address
References
https://www.uml-diagrams.org/class-reference.html