9. UML Object diagram

We have discussed class diagrams so far. But class is an abstract thing - it does not actually exist in the physical world.

In order for a class to exist it needs to be 'instantiated'. This means memory has been allocated that is structured to represent the class, its attributes and its methods. This is called an instance of a class otherwise called an object.

UML supports Object diagrams. They are very similar to class diagrams but with one key difference, the attributes have a specific value at the point in time being depicted and the methods have a specific parameter value if they are active at the point in time being depicted.

Carrying on with the train example. An object diagram is shown below

UML Object diagram

The top part of the box now contains the name of the instance and the name of the class, separated by a colon : and underlined to indicate that it is an object, not a class.

For example the train #1 object is described as TRAIN #1 : TRAIN (it does not have to be capitals, I just wrote it like this)

In addition, the attribute values of the object are shown (train type = "Express"). This example also happens to show the parameter values of some of the active methods.

The diagram shows that this train is associated with two journey objects, namely a Malvern to Worcester journey and an onward journey from Worcester to Birmingham.

Multiple object instances

If there are a number of similar objects whose attributes are not important for the diagram, you can depict these as a stack as show below

UML many objects

 

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 object diagram

 

 

 

Copyright © www.teach-ict.com