Object Diagrams

Suppose that an application has a drawing area that is 500 pixels in both height and width that is dived into three regions as follows:

The border should be drawn with a thickness of five pixels.

Using the classes mentioned earlier , the drawing area could be implemented by a Canvas object, each of the three drawing regions by Rectangle objects, and the border width would be handled by associating an appropriately initialized Pen object with the Canvas object.

The class diagram shown earlier does not convey some essential information about the structure of the drawing area. For example, the class diagram does not indicate:

Answers to questions such as these are provided in an object diagram.

An object diagram for the example is shown below. The drawingArea object is an instance of the Canvas class and has pointers to three Rectangle objts (upperLeft, lowerLeft, atRight). Each of the Rectangle objects has a composed Location object. Since the diagram depicts objects, the actual values of each Rectangle object's Location, height and width can be shown in the diagram. Also, the width of the Pen object (aPen) used by the drawingArea object can be shown explicitly.

Last Updated: December 13, 1995 / kafura@cs.vt.edu