Containment implies uses

From CSSEMediaWiki
Jump to: navigation, search
If a class contains objects of another class, then the containing class should be sending messages to the contained objects, that is, the containment relationship should always imply a uses relationship. --Riel's Heuristic 4.5, Arthur Riel 1996

If a class contains an object, but does not use it, the object is useless. In order for this object to be useful to the program, the enclosing class must have an accessor for the object which defeats the Information hiding principle.

Related to

Personal tools