How Objects Interact

You have seen that the actions within an object are its only interface to other objects. Actions form a kind of "wall" that encapsulates the object, and shields its internal information from outside objects. This shielding is called information hiding. Information hiding protects an object's data from corruption by outside objects, and also protects outside objects from relying on another object's private data, which may change without warning. Because an object's actions are its only interface to the outside, one object can act upon another (or cause it to act) only by calling that object's actions. How do they do it? They send messages.

OO programming in REXX, then, consists of sending messages to objects.

Objects respond to these messages by performing an action, returning some data, or both. A message to an object must specify:

So the message format looks like this:

object~action(parameters)

Say the object is the string !iH. Sending it a message to use its REVERSE action:

'!iH'~reverse

returns the string object Hi!.


[Back: Objects Model Things in the Real World]
[Next: Methods Are "Coded Actions"]