Wednesday 11 April 2012

Message Communication

Java - Message Communication :

An object-oriented program consists of a set of objects that communicate with each other. The process of programming in an object-oriented language, therefore, involves the following basic steps:
1. Creating classes that define objects and their behaviour.
2. Creating objects from class definitions.
3. Establishing communication among objects.
Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another as shown in Fig. . The concept of message passing makes it easier to talk about building systems that directly model or simulate their real-world counterparts.



A message for an object is a request for execution of a procedure. and therefore will invoke a method (procedure) in the receiving object that generates the desired result, as shown in Fig.



Message passing involves specifying the name of the object. the name of the method (message) and the information to be sent. For example. consider the statement
Employee.salary(name);


Here. Employee is the object. salary is the message and name is the parameter that contains information.




Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it is alive. 



No comments:

Post a Comment