December 21, 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).
The events illustrated are:
- The message height is sent to the object referenced by the variable alGore.
- A message answer is returned and assigned to the temporary variable rockBottom.
- The message + 6 is sent to the object referenced by rockBottom.
- A message answer is returned and assigned to the object referenced by the temporary variable dizzyHeight.
- 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