An Association Class is a UML construct that enables an Association to have attributes and operations (features). This results in a hybrid relation with the characteristics of an Association and a Class.
When you add an Association Class connection, Enterprise Architect also creates a Class that is automatically connected to the Association. When you hide or delete the Association, the Class is also hidden or deleted.
To add an Association Class to a Class or Deployment diagram, click on the 'Association Class' icon in the Toolbox. Click and hold on the source object in the diagram while you drag the line to the target element, then release the mouse button. Enterprise Architect draws the connector and adds the Class, then prompts you to add the Class name. Note that the names of the Class and the connector are the same. You can also connect a new Class to an existing Association.
You can highlight the Class part of an Association Class in the Project Browser, by selecting the 'Find Association Class' context menu option on the Association connector.
This diagram illustrates an Association Class between model elements. Note the dotted line from the Class to the Association. You cannot move or delete this line.
- If you are applying a stereotype with a Shape Script to an Association Class, be aware that the Shape Script is applied to both the Class part and the Association part; therefore, you might have to include logic in the shape main that tests the type of the element so that you can give separate drawing instructions for Class and for Association
- Such logic is not necessary in the:
- Shape source or shape target, which are ignored by Classes, or the
- Decoration shapes, which are ignored by Association connectors
- If you dissociate the Class from the Association connector, both parts keep their Shape Scripts until the stereotypes are removed.
OMG UML Specification:
The OMG UML specification (UML Superstructure Specification, v2.1.1, p.49) states:
A model element that has both association and class properties. An AssociationClass can be seen as an association that also has class properties, or as a class that also has association properties. It not only connects a set of classifiers but also defines a set of features that belong to the relationship itself and not to any of the classifiers.