How to Draw a UML Association Class May 20, 2010
An association class, which is essentially a class attached to an association, is used to model an association as a UML class. It has its own name, attributes operations, just like any other ordinary class. However, it is described by additional attributes which does not belong to the objects involved in the association. For example, an Enrollment class is added to hold the attribute year between Student class and Course class, but it does not belong to either Student class or Course class.
Let’s take the year of the enrollment of a student in a course as an example:
- We have two classes Student and Course which are linked on the diagram. Draw a class diagram as follows:
- Next, we create a class. Click Class from the diagram toolbar and drag it on the diagram.
- Name the newly created class as Enrollment.
- Click Association Class from the diagram toolbar and drag it from the connector between Student class and Course class to the Enrollment class.
You’ll then be asked if you want the association to have the same name as that of the class (e.g. Enrollment).
We’ve selected ‘No’ in our example here. However, if we had selected ‘Yes’ to synchronize the names, we would have seen something like below.
- To add an attribute to an association class, right click on Enrollment class and select Add > Attribute from the pop-up menu.
- Finally, name the newly created attribute as year.
How to try the sample
Download association-class-sample and unzip it to get the .vpp file.
- Generate Class Diagram from Existing Classes
- Sharing models between class diagram and sequence diagram