Object Interaction Diagrams


 

An object-interaction diagram shows a sequence of method invocations among a set of objects. The important elements of the diagram are the objects involved and the sequencing of the invocations among them. The compact, direct way in which the sequence of invocations is presented in the diagram starkly contrasts with the obscure manner in which the same relationships exist in the source code. In the source code, the sequence of interactions is dispersed, with each class's code containing one part of the sequence. The invocations are also interspersed with the other code in each class. The object-interaction diagram, however, extracts the essential information and presents it in a single, integrated, and succinct form.

An object-interaction diagram is shown below. This diagram involves three objects (aCanvas, aShape, and aLocation). Time flows from the top of the diagram to the bottom; invocations are drawn as horizontal arrows labeled by the name of the method being invoked. Objects appear as thin vertical rectangles when processing invocations; when idle, they are drawn as viertical lines.

 


An Object-Interaction Diagram

The diagram shows the scenario (the sequence of invocations) that occurs when a Canvas object is asked to perform its Scroll method. In this diagram, the aCanvas object receives the Scroll method invocation to initiate the sequence. The aCanvas object uses the MoveTo method to reposition the aShape object at its new viewing position. In this example the aShape object is assumed to be an object in the Rectangle class. To reposition itself, aShape calls its own Erase (from its current location) and Draw (at its new location) methods. In between erasing and drawing, aShape changes its location by using the Change method in the aLocation object. Finally, to perform the erasing and drawing, the aShape object "calls back" to the aCanvas object, using the EraseLine and DrawLine methods of the Canvas class.

 




©1998 Prentice-Hall, Inc.
A Simon & Schuster Company
Upper Saddle River, New Jersey 07458

Legal Statement