Composition

The Composition relationship is used to model the concept that “X is composed of Y”. For example, a Car is made up of a number of Widgets.

This can be drawn in either of the following ways in the Business Object Modeler:

  • In the first example, there is a line drawn between the Car and Widgets, which is labelled "parts".
  • In the second example, there is a "parts" attribute in the Car class.
    Note: At runtime, these two approaches are treated identically. It does not matter which is used.

The Composition relationship is also known as the Containment relationship.

It is important to understand that in this kind of relationship, if a Car object is composed of a number of Widget objects, those Widgets cannot be components with other Car objects.

This makes sense if you consider the example of a steering wheel. It cannot be in two cars at the same time. Also, if the steering wheel from one car was installed into another car, it would no longer exist in the original car.

Similarly, if a Business Object contained in Business Object A is added to Business Object B, it will no longer exist in Business Object A.