python without OO

Davor davorss at gmail.com
Wed Jan 26 22:28:45 EST 2005


I'd like to thank everyone for their replies. The main important lesson 
I got is:

Python does not have that many issues with misuse of OO as compared to 
Java/C++ because it's *dynamically* typed language and extremely 
powerful *dictionary* data structure.

I browsed docs a bit today, and they also confirm what I have believed - 
that OO is totally secondary in Python. In fact, 
object/classes/metaclasses are nothing but *dictionaries with identity* 
in python. Love this approach. In fact, you can very easily implement 
your own *OO model* completely separate of Python's OO model... Now I 
actually strongly believe that Python's author has introduced the whole 
OO model just to attract and make happy OO population... In fact,

*Python's dynamic type checking mechanisms + dictionary is way more 
powerful than Java/C++'s static type checking mechanisms + their OO 
mechanisms*

and you can definitely be more productive using Python's structured 
programming than Java/C++ OO programming :-)... and Python is probably 
the best example why we should have skipped OO all together..

---
second, instead of playing with OO plagued design principles do as follows:

1. separate data, functionality, and structure from each other as much 
as you can (in Python only valid structural element I've seen so far is 
module - ignore objects & classes!)
2. do not assume any have identity (even if the underlying language 
model provides and uses one) - so don't pass them around and crazy stuff...

so you get a nice program with separate data structures and functions 
that operate on these data structures, with modules as containers for 
both (again ideally separated). Very simple to do and maintain no matter 
what OO preachers tell you...

Davor



More information about the Python-list mailing list