[Tutor] OO terms and definitions

dman dsh8290@rit.edu
Mon, 10 Dec 2001 09:56:35 -0500


On Mon, Dec 10, 2001 at 11:24:55AM +0000, alan.gauld@bt.com wrote:
| > Pragmatically they are the same.
| 
| Umm no, there are significant differences. We get regular cries 
| for help from beginners who have defined a function when they 
| meant to define a method! (ie they missed out self...)

See my last paragraph from before,

        except when you get into the semantic details of "function"
        vs. "unbound method" vs. "bound method".

That is a situation where the semantics of how you define it (in code)
become significant.

| > The Java community likes to call them "methods".  The C/C++ community
| > calls them functions (whether they are in a class or not).  
| 
| They shouldn''t - its supposed to be "member functions" when 

Oops, yeah, I forgot the "member".

| > community calls the ones that modify state but don't return a value
| > "procedures" 
| 
| As does the Algol, ADA, Pascal and VB communities(actually VB 
| uses SUBroutine for procedure) Procedure is a commonly used term 
| for a subroutine that does not return a value.
| 
| > You can pretty much use the terms interchangeably, except when you get
| > into the semantic details of "function" vs. "unbound method" vs.
| > "bound method".
| 
| But only if you want to perpetuate the confusion that caused 
| the poster to ask the question! Its much better for everyone
| if we all use the terms correctly IMO!

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.  It becomes even more difficult
when you frequently work with 2 or more languages.  People are
creatures of habit.  If I spend most of my time in python calling the
things "functions", then when I do some java I'll likely call it a
function there, and vice-versa.

If everyone could agree on a single set of correct terms then it would
be easier to prevent the confusion.  In addition, the terms should not
have such slight semantic differences because that makes the
terminology just as confusing as some code.  If you take the Eiffel
approach to the terms, what term do you give to a procedure that
returns a value?  The compiler doesn't prohibit it, you know.

-D

-- 

Q: What is the difference betwee open-source and commercial software?
A: If you have a problem with commercial software you can call a phone
   number and they will tell you it might be solved in a future version.
   For open-source sofware there isn't a phone number to call, but you
   get the solution within a day.