[Tutor] OO terms and definitions

alan.gauld@bt.com alan.gauld@bt.com
Mon, 10 Dec 2001 17:24:27 -0000

> See my last paragraph from before,
> That is a situation where the semantics of how you define it (in code)
> become significant.

Yes that's what I meant.

> | > The Java community likes to call them "methods".  
> The C/C++ community calls them functions 

> Well, what is "correctly"?  I gave 4 examples of correct, but
> different usages (or non-usages) of the terms, and each is considered
> correct by their respective community.  

If used correctly the terms are consistent. A method is a commonly 
understood term throughout all OO communities. The fact that the C++ 
community happen to have a specific term (member function) to define 
how they implement methods is neither here nor there. What is 
definitely wrong and should be avoided is calling methods functions. 
They are fundamentally different concepts.

[ In passing, it is also important to distinguish methods from 
messages, since in some languages the method has a different 
name to the message. ]

> when you frequently work with 2 or more languages. 

It can be slightly more confusing I agree but as I said in a 
previous post it is becoming much more consistent. Method is 
now a pretty standard term as is class. Function and 
procedure have been standard in CS terms for years.

> things "functions", then when I do some java 

Functions in Python are different from methods. If you use the 
distinction consistently you avoid confusion not cause it.
Methods are "bound functions". Functions are "unbound functions"!
There is a difference and whichever term we use they remain 

> If everyone could agree on a single set of correct terms 

They pretty much have done, bar some minor semantic issues.

> .....  If you take the Eiffel
> approach to the terms, what term do you give to a procedure that
> returns a value?  

A function.
A procedure by definition does not return a value. 
Thus if we all stick to the accepted correct definitions 
then the ambiguity is removed.

In fact checking my copy of OOSC by Meyer, Eiffel itself has 
no keyword distinction beteen function and procedure, they 
are just features. Meyer himself clearly makes the distinction 
in the book on the basis of whether they return a value(function) 
or not(procedure). When he is talking about the general 
concept (ie beyond classes) he uses the term "routine". 
Meyer is always very precise in his terminology in my experience.

> The compiler doesn't prohibit it, you know.
The compiler just sees a "feature".
Semantically the difference exists and is clear.

Alan g.