Currently we have a structure like the following in our UML Class Diagram:
Node --1------------*-- Data
^ ^
| |
SpecialNode--1----*--SpecialData
E.g. SpecialNode is a specialization of the class Node and SpecialData is a specialization of the class Data.
The idea is that each SpecialNode only has SpecialData, and no ‘normal’ Data.
However, some would argue that since a SpecialNode is a Node, it can have relationships to both Data and SpecialData.
Is there any reference material available that would clarify if SpecialNode can have only SpecialData? If not, how could we inforce this (in a clean way).
Kind Regards,
Joos
Indeed, such modeling implies that
SpecialNodeinherits all the properties ofNode, includingData. Otherwise it would contradict the Liskov Substitution Principle which is an important rule for good design. I would suggest not to define yourNodeandSpecialNodeas “having”DataorSpecialDatabut rather have an interface toData. ForNodeit will be associated withDataobject and forSpecialNodeit will be associated withSpecialDataobject.