Creating composite classes

Instances in a composite class are called parts. To identify a component in code (actions or operations), use the expression instance-of-composite.name-of-part. The multiplicity of a component is relative to each instance of the composite containing it. For example, each car has one engine.

About this task

If the multiplicity is well defined (such as 1 or 5), IBM® Rational® Rhapsody® creates the components at run time, when the composite is instantiated. If an association is instantiated by a link, the product initializes the association at run time.

When a composite is destroyed, it destroys all its components.

Procedure

  1. Click the Composite Class tool.
  2. Click in the diagram, or click-and-drag to create the composite class. The new composite class is displayed in the diagram.

Results

Because a composite class is a container class, you can create objects and relations inside it. A composite class uses the same Features window as objects and parts. Another way of having the functionality of a composite class is to use a composition.


Feedback