Why is it said that "messages are sent to methods"?

In object-oriented programming, it is said that messages are sent to methods. In this context, why is the word "method" used instead of "procedure" or "function"?

In other words, why was the word "method" introduced to programming?


Solution 1:

The name 'method' came from a philosophy of object orientation that was fundamentally about message-passing: the object model of the universe can be summed up as "there are objects; they send each other messages". Eventually, of course, there are objects that actually have some effect on the outside world, but that's a detail that's swept under the carpet in the name of uniformity.

When an object receives a message, it goes on to send further messages to other objects. Naturally, it has to have a way of deciding what messages to send - a procedure to follow, a routine to go through, or, if you like, a method to use.

You can see this usage in the Blue Book, the original description of Smalltalk-80 (this is from the first section, Classes and Instances):

An object's public properties are the messages that make up its interface. All instances of a class have the same message interface since they represent the same kind of component. An object's private properties are a set of instance variables that make up its private memory and a set of methods that describe how to carry out its operations.

Solution 2:

The terminology is not well designed in my opinion. I believe the earliest usages talked "sending a message to an object", which at least can be pictured. Object and message were in use before method, probably with Smalltalk or earlier. I think method must have been introduced by someone who desperately wanted to divorce the method from old hat functions (or procedures). They differ slightly in the hidden nature of the implementation and the hidden instance parameter ("this").

Solution 3:

It's simply to distinguish a function that's part of a class or object from one that isn't.

Solution 4:

Method is used instead of procedure or function because the authors wish to maintain a distinct terminology for object-oriented programming that separates it from procedural programming.

In procedural programming your major primary units are procedures or functions.

In object oriented programming your major primary units are classes and instances (i.e. objects) of those classes. Methods only exist in the context of a class or an instance.

A rose by any other name would smell as sweet, but sometimes it helps to have a distinct name when you want to break old habits and look at things in a new way.

Solution 5:

In the OO-Paradigma messages are send to an object. Technically this will be accomplished by invoking a method.

For more details see also: Object Oriented