Aggregation (Containing)
The aggregation inter-class relationship describes an object that is composed of separate, smaller objects that function together. The Employee and Job classes provide an example:
• The Job object contains attributes (such as Title, Class, and Pay) that describe a specific job held by a specific employee during a specified time.
• An Employee object consists not only of scalar attributes (such as LastName and HireDate) but also of a complete job history for each position the employee has filled at the company. (For a full description of this class, see
How Polymorphism Works (see
How Polymorphism Works).)
The JobHistory attribute of the Employee class, which is an array of Job objects, exemplifies an aggregation relationship.
Although the data pertaining to employees is stored in several database tables and structured in different user classes, the application user who manipulates the Employee object does not think in terms of the separate objects composing the whole, but works with the aggregate as a single object. Aggregate objects allow far more complicated structures than simple objects.
An example of an OpenROAD system class that follows this relationship model is TableFields. TableFields contain such other classes as an optional scrollbar (ScrollBarField), an optional control menu (ControlButton), and an array of column fields (StackField).
Most objects participate in both types of relationships simultaneously. For example, Employee and Job are both members of an inheritance hierarchy and share an aggregation relationship.