Python Productivity over C++
Gordon McMillan
gmcm at hypernet.com
Mon Jun 12 15:47:15 EDT 2000
Neurocrat wrote:
>gmcm at hypernet.com (Gordon McMillan) writes:
>
>[snip]
>
>> One point worth reiterating is that where the app (in a C++ design)
>> calls for lots of related classes, you will probably only have a
>> handful in Python. Of course, this means discarding classical "OOP"
>> thinking, and desinging more in the "component" style. But this can
>> yield an order of magnitude all by itself.
>
>If it's worth reiterating, would you mind elaborating on this
>somewhat?
Simply that in Python, inheritance doesn't necessarily have anything to do
with runtime behavior. (You can, of course, introduce that dependency, but
you'd be well advised not to.)
The classic example would be 2 base classes (say Event and View), and you
want view->process(event) to get to both the right overload and the right
override. In C++ (or Java) that takes spelling out the whole num(View
derived classes) x num(Event derived classes) matrix, and bouncing the
message back and forth (first to get the overload and then to get the
override). In Python, it takes view.process(event).
That is, it's the interface that matters (not the derivation), and you
don't even have to get formal about that.
Not that you should throw out everything you know about pre-condions and
post-conditions and substitutability; but you don't have to spend all week
convincing the compiler you know what you're doing.
- Gordon
More information about the Python-list
mailing list