What is a Message?
They are used by software objects to communicate with
other software objects.
Object A: the Transmitter
Object B: the Receiver
Sometimes, the receiving object needs more information
so that it knows exactly what to do; for example, when you want to
change gears on your bicycle, you have to indicate which gear you
want. This information is passed along with the message as arguments
or parameters. The next figure shows the three components that
comprise a message:
- The object to which the message is addressed (YourBicycle)
- The name of the method to perform (changeGears)
- Any arguments/parameters needed by the method (lowerGear)
Messages provide two important benefits:
-
An object's behavior is expressed through its
methods, so (aside from direct variable access) message passing
supports all possible interactions between objects.
-
Objects don't need to be in the same process or
even on the same machine to send and receive messages back and
forth to each other.
Difference between Messages & Proceedure Calls
1) Message has a receiver (an object to which message is sent)
2) Interpretation of message is up to receiver.
|