Take the 2-minute tour ×
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
4  
This question might be better suited for SO or programmers.stackexchange. I suspect the answer is more 'techie' related than language related. –  oosterwal Feb 26 '11 at 5:01
1  
@oosterwal: you're probably right; the fact that English words are typically used for the terminology is pretty much incidental. –  mgkrebbs Feb 26 '11 at 5:09
1  
I haven't come across messages being sent to methods, only objects. I believe you are describing an incorrect use. May i ask where you encountered this? –  Tom Anderson Feb 26 '11 at 20:04
    
Tom, I agree it is probably a misuse but the question is really about use of the word method. –  broiyan Jul 20 '11 at 0:50
add comment

7 Answers

up vote 3 down vote accepted

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

share|improve this answer
add comment

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").

share|improve this answer
2  
If the marketing push was for object oriented programming as a new paradigm in opposition to functional programming or procedural programming then you do not want functions or procedures to be key parts of the lexicon. –  Henry Feb 26 '11 at 9:47
    
In correct use, one still sends a message to an object; the object handles it using a method. –  Tom Anderson Feb 26 '11 at 20:06
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
    
In functional programming your primary units are functions as well. Take a look at Javascript, for example. Functional programming is what makes map/reduce algorithms possible. See Joel Spolsky's article on this topic. –  Robusto Feb 26 '11 at 12:25
1  
@Robusto, not strictly true. Map/fold is possible in OO languages. The relevance of functional languages to map/fold is that they are more natural and more central to the idiomatic ways of using those languages. –  Peter Taylor Feb 26 '11 at 21:36
add comment

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

A method is something more than a function; as the word function was already used in programming with a specific meaning, it has been necessary to introduce a new word in the programming jargon.

share|improve this answer
add comment

For me, it just complies with common sense.
Say, you have an object; for example, a garage. Its function is to store cars, but it isn't represented by a function as a part of the object. However, the garage lives up to its function by way of methods: you drive up to the garage, press a button on your keychain (thus sending a message) and the method that lifts the door is invoked.
It is not the garage's function to lift the door, but it can do it. It's just one of the many methods that help achieve a certain goal.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.