March 19, 2024

Object-Interaction Diagrams

 

In the code below, two instances of the HoverFrog class are referenced by the variables alGore and georgeWBush. (Note that for alGore you could substitute johnKerry. It seems that some things never change.)

Note the declaration of temporary variables, these are only available for use within the expression series that follows.

| rockBottom dizzyHeight |
alGore := HoverFrog new.
georgeWBush := HoverFrog new.
rockBottom := alGore height.
dizzyHeight := rockBottom + 6.
georgeWBush height: dizzyHeight.

An object-interaction diagram is used to illustrate both the messages and message answers resulting from the last three lines of code.

Messages are denoted by solid horizontal arrows. Message answers, which are objects not messages, are illustrated with horizontal broken arrows. All vertical lines are objects. The 'stepped' ordering of the objects and messages illustrates the fact that there is a time-based aspect to this process. (a similar diagram is used in software development).

object-interaction diagram

The events illustrated are:

  1. The message height is sent to the object referenced by the variable alGore.
  2. A message answer is returned and assigned to the temporary variable rockBottom.
  3. The message + 6 is sent to the object referenced by rockBottom.
  4. A message answer is returned and assigned to the object referenced by the temporary variable dizzyHeight.
  5. The message height: dizzyHeight is sent to the object referenced by the variable georgeWBush.

georgeWBush will return itself as a message answer, but is omitted as it is not used by another object.

Next page » Textual representation of objects (print-strings)

Previous page « Assignment exercise

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Up to top of page