Method

Monday, January 14, 2008

Method

Method
How do receiving objects interpret messages from the senders? How are the messages processed?



Each message has code that associated with it. When an object receives a message, code is excercuted. In other words, these messages determine an object's behavior and the code determines how the object carries out each message. The code that is associated with each message is called a method. The message name is also called the method name due to its close association with the method.

When an object receives a message, it determines what method is being requested and passes control to the method. An object has as many methods as it it takes to perform its designed actions.

Refer to the following diagram, name, name:, address and name:address are method names for the Student object . When the Student object receive the name message, the name message passes control to the name method defined in Student.





Methods that operate on specific objects are instance methods and messages that invoke instance methods are called instance message. Methods that operate on specific classes are class methods.

Methods are similar to subroutines, procedures, or functions found in procedural languages (C, Pascal). For example, a method name equates to a subroutine name, and the code for the method equates to the code found in a subroutine. Sending a message to an object is similar to calling a subroutine.

0 comments:

 

Tamil Video Songs | Make Money Online