Chapter 6. Object Diagrams

An object diagram is a snapshot of the objects in a system at a point in time. Because it shows instances rather than classes, an object diagram is often called an instance diagram.

You can use an object diagram to show an example configuration of objects. (See Figure 6.1, which shows a set of classes, and Figure 6.2, which shows an associated set of objects.) This latter use is very useful when the possible connections between objects are complicated.

Class diagram of Party composition structure

Figure 6.1. Class diagram of Party composition structure

Object diagram showing example instances of Party

Figure 6.2. Object diagram showing example instances of Party

You can tell that the elements in Figure 6.2 are instances because the names are underlined. Each name takes the form instance name : class name. Both parts of the name are optional, so John, :Person, and aPerson are legal names. If you use only the class name, you must include the colon. You can show values for attributes and links, as in Figure 6.2.

Strictly, the elements of an object diagram are instance specifications rather than true instances. The reason is that it’s legal to leave mandatory attributes empty or to show instance specifications of abstract classes. You can think of an instance specification as a partly defined instance.

Another way of looking at an object diagram is as a communication diagram (page 131) without messages.

When to Use Object Diagrams

Object diagrams are useful for showing examples of objects connected together. In many situations, you can define a structure precisely with a class diagram, but the structure is still difficult to understand. In these situations, a couple of object diagram examples can make all the difference.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.121.160