[Tutor] OO terms and definitions
Mon, 10 Dec 2001 11:17:05 -0000
> I am a little(or is that a lot) confused about some OO terminology.
OO terminology is beginning to settle down but for a long time there
have been numerous different terms for the same concept and subtle
differences in usage of these terms too. It is confusing even to
> I have some quite a bit on the web and I have seen all sorts
> of definitions for the following terms:
A Module in the pure sense is any kind of reusable software component.
It could be a function, a procedure, a class, a file, or a library.
Anything that is atomic and can be reused can be called a module.
In Python a module has the more precise meaning of a file.
The file can contain constant/variable definitions, clsass definitions
and function definitions. It can even contain executable code
(ie executed when the module is loaded)
Geneally refers to a description, in code, of some object type.
Technically a function is a (possibly parametereised) executable block
of code which returns a value. A procedure looks a lot like a function
but does not return a value. Functions and procedures exist outside of
In python procedures are just functions that return None by implication.
They are executable blocks of code existing outside a class but may,
or may not, be inside a module.
A method is technically the code block executed on receipt of a given
message by an object. It usually looks a lot like a function definition
but is always defined within a class. In python it has a first parameter
representing the current instance, named by convention 'self'.
A function that does not return a value(see function above).
> It seems to me that there is a hierarchy to some degree
Only to a degree, and the extent of that depends on the programming
language. Languages like Lisp/Scheme change the picture significantly
compared to Python.
> Does a Module always have a Class?
No, it may not even have functions!
> How do Function, Method and Procedure differ?
See above but Functions/Procedures exist outsife classes. Methods
are functions insiode classes that are activated by the owning
object receiving a "message". In Python a message looks a lot like
a function call...
HTH, For more on this look at my web tutor under
"modules & functions" and the OO topic.
Author of the 'Learning to Program' web site