Heterogeneous Collections of Objects
Every collection of relationships is homogeneous. In any relationship collection, each item is a relationship of the same relationship type. Collections of objects, however, can be either homogenous or heterogeneous (that is, the items can have different classes).
A collection of objects can be heterogeneous for the following reasons:
- The Repository Type Information Model (RTIM) allows each interface to be implemented by many classes.
- The RTIM expresses each relationship type as an association between two interfaces rather than as an association between two classes.
Each relationship type describes how the objects of classes implementing particular interfaces can be related. Thus, if several classes implement a particular interface, some relationship types involving that interface can yield collections whose target objects span several classes. As you prepare programs that manipulate such collections, do not assume that the collections will contain homogeneous sets of objects.
Note Plan for change; do not assume that your information model will remain unchanged. Although a particular relationship type of your information model might associate two interfaces that are implemented by exactly one class each, you might someday create other classes that implement those same interfaces. Any user who enlarges the number of classes implementing either of those interfaces introduces the possibility for heterogeneous collections of objects. If your programs that use those collections are dependent upon homogeneous collections, you must rewrite them as soon as you implement the interfaces with several classes. To protect your programs from this cause of obsolescence, write them assuming that any collection of objects can be heterogeneous.