¥The union
pattern is used to represent different forms of related data with some common behavior.
¥The pattern consists of an abstract
class A together
with a collection of variant subclasses B1, ..., BN extending A. An abstract class cannot be instantiated using new.
¥The collection of classes A, B1, ..., BN is called a union hierarchy and A classes
is called the root class of the hierarchy.
¥The common behavior is codified by a set of methods in A, which may be abstract Each such method m has an associated contract that that the implementation in each
variant class must obey.