[Tutor] OO terms and definitions
Sun, 9 Dec 2001 15:19:27 -0500
On Sun, Dec 09, 2001 at 10:27:45AM -0800, Frank Peavy wrote:
| I am a little(or is that a lot) confused about some OO terminology.
| I have some quite a bit on the web and I have seen all sorts of definitions
| for the following terms:
| It seems to me that there is a hierarchy to some degree, as idented above.
| And, I am under the impression that a Module is usually a file with a .py
| extension that contains the other items.
| Does a Module always have a Class? I am under the impression that this is
| not the case.
So far so good.
Note that in some languages classes and functions can nest, and others
have restrictions on it. Python falls in the former category. In C
and C++ there is no nesting allowed. In Java a class can be nested
inside another class or method, but methods cannot be nested in other
methods. I don't know if Eiffel allows nesting or not.
| How do Function, Method and Procedure differ? Or are they the same...?
Pragmatically they are the same.
The Java community likes to call them "methods". The C/C++ community
calls them functions (whether they are in a class or not). The Eiffel
community calls the ones that modify state but don't return a value
"procedures" and the ones that return a value but don't modify state
"functions" (and they don't like ones that do both).
Technically in Python a "function" is not part of a class. Either it
is at the module level or it is a nested function in the local
namespace of another function. A "method" is part of a class. If it
is unbound it has no instance associated with it, if it is bound it
has an instance associated with it.
You can pretty much use the terms interchangeably, except when you get
into the semantic details of "function" vs. "unbound method" vs.
In his heart a man plans his course,
but the Lord determines his steps.