Object Diagram

Object Diagram

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

You can use an instance 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 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 and :Person are legal names. You can then show values for attributes and links, as in Figure 6-2.

You can also think of an object diagram as a collaboration diagram without messages.