lotus

previous page: 1.17) Is An Object A Class? (Object-Oriented Technology)
  
page up: Object-Oriented Technology FAQ
  
next page: 1.19) What Are Multi-Methods And Multiple-Polymorphism? (Object-Oriented Technology)

1.18) What Is A Method? (And Receiver And Message) (Object-Oriented Technology)




Description

This article is from the Object-Oriented Technology FAQ, by Bob Hathaway rjh@geodesic.com with numerous contributions by others.

1.18) What Is A Method? (And Receiver And Message) (Object-Oriented Technology)

A method implements behavior, which is defined by [Booch 91, p80]:

Behavior is how an object acts and reacts, in terms of its state changes
and message passing.

A method is a function or procedure which is defined in a class and typically
can access the internal state of an object of that class to perform some
operation. It can be thought of as a procedure with the first parameter as
the object to work on. This object is called the receiver, which is the object
the method operates on. An exception exists with C++'s static member functions
which do not have a receiver, or "this" pointer. The following are some common
notations for invoking a method, and this invocation can be called a message
(or message passing, see below):

receiver.message_name(a1, a2, a3)
receiver message_name: a1 parm1: a2 parm3: a3

Selector would be another good choice for message_name in the above examples,
although keywords (or formal parameter names, like named parameters) are
considered part of the selector in Smalltalk (and hence Objective-C).

If done statically, this can be referred to as invocation, and message passing
if done dynamically (true dynamic binding). Statically typed dynamic binding
(e.g. C++ and Eiffel) is really in between (checked function pointers).

See also section 1.19 below for a discussion on the functional (prefix) verses
message based (receiver based) notation.

 

Continue to:













TOP
previous page: 1.17) Is An Object A Class? (Object-Oriented Technology)
  
page up: Object-Oriented Technology FAQ
  
next page: 1.19) What Are Multi-Methods And Multiple-Polymorphism? (Object-Oriented Technology)