lies about OOP

Steve Holden steve at holdenweb.com
Thu Dec 16 11:42:46 EST 2004


Dave Benjamin wrote:

> In article <mailman.7828.1103172841.5135.python-list at python.org>, Adam DePrince wrote:
> 
>>On Tue, 2004-12-14 at 18:27, Roy Smith wrote:
>>
>>>Terry Reedy <tjreedy at udel.edu> wrote:
>>>
>>>>I did not really 'get' OOP until after learning Python.  The
>>>>relatively simple but powerful user class model made more sense to
>>>>me than C++.  So introducing someone to Python, where OOP is a
>>>>choice, not a mandate, is how *I* would introduce a procedural
>>>>programmer to the subject.  YMMV.
>>>
>>>OOP is a choice in C++ too.  You can write procedural C++ code; no
>>>need to use classes at all if you don't want to.  Something like Java
>>>is a different story.  Java *forces* you to use classes.  Nothing
>>>exists in Java that's not part of some class.
>>
>>Static methods act like C functions.  Sure, they are members of classes,
>>but in name only.  Besides, just as you can use a procedural language in
>>an OO fashion with enough programmer discipline, you can write in a
>>procedural style with an OOP language with sufficient rebellion.  Just
>>use one class, put everything in it and create one instance on startup.
> 
> 
> Maybe I'm reading this wrong, but it seems like you're implying that
> procedural code is inherently unmodular. Why would just one class/instance
> suffice to represent a procedural program? I think of namespacing and code
> organization as broad concepts that cut across all styles of programming.
> 
Well I can't speak for Terry, but I've observed in the past that 
object-oriented system complexity can grow beyond the programmer's 
ability to manage it when objects sprout too many methods.

Effectively each instance's namespace becomes a set of global variables 
that the methods use to intercommunicate. This style of OO programming 
sometimes drives me nuts (IIRC it was the library modules based on 
SocketServer that drove me to this conclusion).

> Interestingly, Python's main unit of modularity is the "module", not the
> "class". A direct translation of a typical Python module to Java would look
> something like a Java class containing only static methods and inner classes.
> Even this would be considered rebellious within the context of ordinary Java
> programming.
> 
Well Java got some things right, but one of the things it got wrongest 
was the absence of functions and procedures and the consequent need to 
provide class methods. Though for the life of me I don't *really* know 
why I find it acceptable in Python to have to write module.func(args) 
when I dislike having to write class.meth(args) in Java.

perhaps-i'm-just-old-and-crotchety-ly y'rs  - steve
-- 
Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119



More information about the Python-list mailing list