7. UML diagram: associations (1)

Most systems have classes that are associated with one another.

For example the Train Journey class may have a train class associated with it i.e. a physical train has been assigned to the journey. This is an association between classes

UML association

There are five kinds of association, but the commonest ones are bi-directional and uni-directional associations. The standard one is bi-directional and is depicted as a line between the classes as shown above. The uni-directional one is described on the next page.

In addition to the line, there is a multiplicity indicator. This indicates how many of one class instance is associated with the other one. The 0..1 next to the train class means that when an instance of a journey exist, there will be up to 1 train associated with it. A zero train instance means that a journey instance would not have been assigned a train at that point in time

The 0 .. * next to the journey class means that a particular train instance is associated with any number of journeys (the * bit) - or no journeys at all if it is a brand new train for example.

The other part of the diagram is the 'role name'. This describes the role the class takes in relation to the other class. For example a train class takes on the role of 'assignedTrain' as far as the journey class is concerned. And each journey takes on the role of 'assignedJourney' as far as the train class is concerned.

Part of the skill in generating UML diagrams is to be able to partition the system efficiently and clearly. Quite often there are many ways to do it.


Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: UML class association




Copyright © www.teach-ict.com