How to Draw a UML Association Class
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.
Related Articles
- Generate Class Diagram from Existing Classes
- Sharing models between class diagram and sequence diagram
Hi once we selected synchronize association name and association class how to deactivate it please ?
Hi Thierno,
Please try these:
1. Select “Windows > Project Options” from the application toolbar.
2. In the Project Options window, select Diagramming on the left
3. Open the Association tab
4. Look for the option “Synchronize association name with association class” and modify its value.
5. Click OK to confirm.
Thx that solved it