OO Relationships (PPT 11 - 13) Flashcards
What is a relationship?
Collaboration between objects
What is an association relationship?
Association represents a link/memory between objects. Messages may flow in either direction across the association
How do we name an association?
It is stated in terms of the objects being associated. The combination of objects and association name should read like a sentence
How many associations can an object have?
It can have as many as it wants and can also have as many associations between objects as you want
What is a reflexive association?
Associations which involve only one class of object
What are role names?
Used to indicate the role performed by each end of the association
What is multiplicity?
The number of instances of objects which may be involved at either end of the association
What is a composition relationship?
It is a stronger form of association, relates a whole object to its parts. Represented by a line with a filled in diamond on the end. Idea is one object is either physically part of another or is exclusively owned by another one
What is a aggregation relationship?
It is a slightly weaker form of composition. Means a part may outlive the whole it is part of. The owner only has temporary ownership, not exclusive ownership
What is a dependency?
Where objects come into temporary contact with each other during the running of the program
How do we know if we need a relationship?
- If one class creates an instance of another one
- If one class received an instance of another on as input to a method/function
- If one class has an instance of another one as one of its fields/attributes
What is a uni-directional association?
Messages only travel in one direction. Helps protect coupling and reuse
What is a generalisation?
Relationship between a general concept and its more specific forms. Allows parent child hierarchies
What is a superclass?
It is a class which represents a general concept. Defines characteristics and behaviours expected of any type of this class, e.g. shape
What does a subclass inherit?
It automatically inherits all characteristics and behaviour from it parent