Week 5- Modelling requirements and class stereotypes Flashcards
What do we use to model requirements?
We use UML diagrams.
What is a class diagram
A class diagram is a diagram that describes the structure of the system by showing the system’s classes, attributes, methods, and relationship amongst the objects.
What is an association
Associations are solid lines drawn between classes
What does an unlabelled relation(just a solid line) mean by default?
By default, an unlabelled relation means “has a”. For example, Player has an address.
If it is unlabelled an undecorated, it also means
“one-to-one”, so its both “has-a” and “one-to-one”
Player—————-(solid line)———- Address
What are constraints?
Constraints on associations, are placed at the ends of a relationship.
They denote HOW MANY INSTANCES of the classes may be a member of the relation at run time.
What does one-to-one constraint mean?
Player (1) ——————– (1) Address
This means that A player has an address and EACH address is associated with ONE player (1-1)
Labelling Associations: Can associations be labelled with identifiers?
Yeah they can be used to provide specific interpretations of the association, instead of a default ‘has a’ or ‘has some’.
How would you read this (refer to lect slide if no understand..)
Player ————– (workAddress) Address
————– (homeAddress)
A player has a workAddress and a homeAddress
How would you read this
Team () ——playsFor———–(0..) Player
A team consists of zero or more players
and a player can play for many different teams
How would you read this
Manager(0..1) ——managers>—– (0,1,2)Team
A maanger can manage no, one or two teams and a team can have at most one manager.
What are reflexive associations?
Please go through lecture example as well
A reflexive association is whereby a class maintains an association to themselves. Objects of the same class will have references to each other
(a) What is “Uses/Depends on”? For example, When does Class A depend on Class B?
(b) How do we represent a dependency?
Class A depends on Class B if at some point it uses class B.
In code, Class A would be using a Class B method (refer lecture notes if no get)
We represent a dependency by a dotted line and open arrow indicating the dependency direction.
What is an aggregation?
How do we represent aggregation?
Patient(1)—<>(1)Patient Record
Consultation (1)—<> (1)Patient Record
In the real world, objects are made up of different parts.
UML provides a special type of association between classes to express the “IS PART OF” relationship called Aggregation
A”Patient Record” is an aggregate that contains exactly one “Patient” and one or many “Consultations”. It’s important to note that aggregation does not imply ownership. Unlike composition (a stronger form of aggregation denoted by a filled diamond), in aggregation, the lifecycle of the part is not strictly tied to the lifecycle of the whole; the “Patient” and “Consultation” can exist independently of the “Patient Record”.
How do indicate composition?
The plain/full diamond indicates that the contained objects are not shared
When the container object is destroyed, the contained objects disappear with it
Comparison between composition and aggregation based on word choice
(OWNS) vs (USES)
A text editor owns a buffer (composition)
A text editor uses a file (aggregation)
When Text Editor is closed, Buffer is destroyed but not the file
Remember to look at the code implementation as well to see the difference, in lecture slides