To be or to have? That is the question .
This question is less philosophical than you think.
The question returns with each and every OO model when classifying relationship Types.
A simple example:
- A cup has a few pens and pencils.
- A pen is a writing utensil.
- A pencil is a writing utensil as well.
To be or to have is the technical difference between
-
An association is always about "having" something.
A house has dwellers.
A newspaper has readers.
A reader has subscriptions.
A cup has pens.
A cup has pencils.
An association is instance specific.
Two houses have two different sets of dwellers, the set of readers for one newspaper differs from that of another, etc.
Technically speaking a association is specific to an object or to a
row
in a
database.
An association can change during the lifecycle.
A house can get different dwellers.
A newspapers can gain new readers.
A pencil can move from one cup to the other.
A row can get a new value for a
foreign key.
-
A specilisation is about 'being'.
It has to do with identity.
Every pen is a writing utensil
and so is every pencil.
A pen that is not a writing utensil, is not a pen.
Technically speaking it's defined at class level.
That class may be abstract, such as writing utensil.
There are no instances of writing utensil.
A specialisation is something that lasts for life.
It's a property given to an object at birth, which never changes.
A pencil remains a writing utensil its entire life.
Once born as a pen, you'll never be a cup.
Fine, so much for the theory, it's about time for a short, very confusing quiz:
- Do you have a rental home or are you a house owner?
- Do you have a permanent job or are you an entrepreneur?
- Do you have a car or are you a train commuter?
Till next week,
Nut
Related story:
Specialisation
|