L11: Modelling Structure Flashcards
What is a system in object oriented design?
In object-oriented design, a system is a collection of interacting objects
What are objects in object oriented design?
Objects of a class share the same attributes, operations and relationships but may have different state
Identity
Unique to each other
State
Values of its attributes and the relationships it has to other objects at a particular point in time.
Some attribute values may change over time, while others will stay the same.
Behaviour
Operations that can be invoked on the object
State can affect behaviour, and behaviour can affect state (state transition)
What is a class in OOD?
A way of grouping objects with similar structure and behaviour (template)
A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics, but not necessarily the same attribute values.
Each object is an instance of exactly one class.
What is a class diagram in OOD?
A class diagram shows the class name, attributes and methods and their respective scope and visibility.
What is the scope of attributes/methods?
The scope of attributes or methods tells whether they belong to each object created (no adornment) or the class (underlined in diagram, static).
What is the visibility of a class, and how is it denoted?
The accessibility of an element- who can see it.
Sometimes, methods only need to be accessed within a class.
+ : public, accessible to any class
- : private, accessible only within the same class
# : protected, accessible only within the same class or its subclasses
~ : package, accessible to any class in the same package
How are derived attributes denoted?
/
What do relationships model?
Interactions between classes are modelled by relationships
Relationships model how objects of different classes work together
- Association
- Aggregation
- Composition
- Generalisation
How are relationships between classes denoted?
In increasing order of strength:
Dependency: Dotted line with arrow
Association: Straight line
Aggregation: Straight line with hollow diamond
Composition: Straight line with coloured in diamond
Generalisation/Inheritance: Straight line with triangle arrow
What is association in OOD?
- A design-time relation between classes
- Specifies that at runtime instances of those classes have a link and be able to request services from one another
- Associations can have a name to describe the nature of the relationship
- An additional arrowhead can be used to indicate the direction in which to read the name
What is the syntax for association?
An association name
- Verb phrases, indicating an action that the source object performs on the target object
A role name
- Names the class on one or both ends of the association, indicating the role that
objects play when they are linked by this association
Multiplicity
- Constrains the number of objects of a class that can be involved in a particular relationship at any point in time
Navigability
- Direction from an object of the source class to one or more objects of the target class
What are the association roles?
Objects can play a specific role in a relationship.
Roles are shown as a name placed near the end of an association.
What is multiplicity on an association?
Multiplicity on an association end indicates the possible number of instances from that end that can participate in the association at runtime.
0..1
1
0..*
1..*
0..n
1..n
What is the navigability of an association?
The direction of navigability or message flow of the association may be specified by adding an open arrowhead.
No arrowheads means that the association is bidirectional.
What is aggregation in OOD?
A special kind of association indicating the existence of a “whole- part” relation between two classes
Object of one class owns object of another class, but those part objects may be shared by objects of another class.
E.g., a wallet has money, but the money does not need a walled to exist. If the wallet that money was in is deleted, the money still exists.