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:

  1. We have two classes Student and Course which are linked on the diagram. Draw a class diagram as follows:

    Student class and Course class

    Student class and Course class

  2. Next, we create a class. Click Class from the diagram toolbar and drag it on the diagram.

    Create a class

    Create a class

  3. Name the newly created class as Enrollment.

    Name it as Enrollment

    Name it as Enrollment

  4. Click Association Class from the diagram toolbar and drag it from the connector between Student class and Course class to the Enrollment class.
    Create association class

    Create association class

    You’ll then be asked if you want the association to have the same name as that of the class (e.g. Enrollment).

    Synchronize Association Class Name

    Synchronize Association Class Name

    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.

    Association Name = Class Name

    Association Name = Class Name

  5. To add an attribute to an association class, right click on Enrollment class and select Add > Attribute from the pop-up menu.

    Add an attribute

    Add an attribute

  6. Finally, name the newly created attribute as year.

    Name the newly created attribute as year

    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

Related Links