[ Team LiB ] Previous Section Next Section

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.

Figure 6.1. Class diagram of Party composition structure

graphics/06fig01.gif

Figure 6.2. Object diagram showing example instances of Party

graphics/06fig02.gif

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.

    [ Team LiB ] Previous Section Next Section