Messages are the communication mechanism between objects.
Messages enable one object to invoke an action (method) in another object.
Messages comprise of three components:
- The object being addressed
- The method to perform
- Any parameters required by the method
In this example, the driverObject is invoking the Motorbike’s public accelerate method, with a parameter of 160 (e.g. to indicate the desired speed), as indicted by the purple coloured items.
The driver object has not directly changed the state of the object (in this case the speed), but has requested that the object utilises its own method to make the desired effect.