Object Relationships
Association
- The relationships between objects and classes can be classified into three
types: Association, Aggregation, and Inheritance. An
Association describes how two objects are related. The verbs used to connect
the objects describes the relationship or Association between the objects.
Aggregation and Inheritance each model a special type of Association between
objects. Notice that the objects are nouns. The association between them is
a verb. Here are some example Associations:
a Student takes a Course
a Lion lives in a Den
a Boat floats in the Ocean
Aggregation
- Aggregation represents an ownership between objects. It is a composition of
objects that define another object. The verb used to describe Aggregation
is 'Has A'. If 'Has A' can be placed between the nouns and read as a
sentence, then the relationship between the objects is an Aggregation.
Some example Aggregations are:
Spot Has A Tail
a Dog Has A Coat
a Dog Has An Eye
a Student Has An Exam
a Boat Has A Hull
Inheritance
- Inheritance models the subclassification or hierarchy of objects. The verb
used to describe Inheritance is 'Is A'. If 'Is A' can be placed between
the two nouns and read as a sentence, then the relationship between the
objects is an Inheritance.
Student is a Teacher // NO
Spot Is A Dog
a Dog Is A Canine
a Canine Is A LandMammal
a Grader Is A CollegeStudent
a CollegeStudent Is A Person
Example Questions
- what is the relationship between the two pairs?
Car
Engine
Car
Ford