Class Diagram Flashcards
What are the two families of software models?
Static
- class diagrams, etc
Dynamic
- activity diagrams, use case diagrams, etc.
What is a class diagram?
Shows the classes of a system and the associations between those classes.
Each class may have some knowledge about associated classes.
What are the main symbols shows in UML?
Classes
associations - linkage between data
attributes
operations - methods
generalizations - group classes into inheritance hierarchies
What is an association?
Used to show how classes are related to each other.
What is multiplicity
Defines how many instances can be associated at any given moment.
[Employee] * ———————– 1 [Company]
What is generalization?
Usually represents some kind of inheritance, as a clarification
Example, doctor is the parent class of clinic_doctor and hospital_doctor.
Represented by empty arrows.
Associations vs generalizations
Associations describe the relationships that will exist between instances at run time.
Generalizations describe relationships between classes in class diagrams
What is an aggregation
special association that represent “is part of” association.
example:
Vehicle<>——–Vehicle part
What is composition
A stronger version of the aggregation. If the aggregate (vehicle) is destroyed, then the parts of it must be destroyed as well.
What are interface
And interface describes a portion of the visible set of objects
Think of the java interface.
ATM class and employee class can call widthdraw/deposit on the interface
Different notations for multiplicity
0..1 No instances or one instance A flight seat can have no or one passenger only
1 Exactly one instance An order can have only one customer
0..* or * Zero or more instances A class can have zero or more students
1..* One or more instances (at least one) A flight can have one or more passenger
Direction and bi-directional association
direcitonal:
car -> customer
car has a customer attribute
bidirectional:
car <-> customer
car has customer attribute, customer has car attribute
When to use an aggregation:
As a general rule, you can mark an association as an aggregation if the followings are true:
You can state that
the parts ‘are part of’ the aggregate
or the aggregate ‘is composed of’ the parts
When something owns or controls the aggregate, then they also own or control the parts