[Tutor] designing POOP
Kent Johnson
kent37 at tds.net
Thu Feb 7 13:25:06 CET 2008
Alan Gauld wrote:
> "Kent Johnson" <kent37 at tds.net> wrote
>> The writings of Robert C Martin have taught me a lot about good
>> design
>> and agile development. They don't all apply to Python
>
> Martin is very good on Agile, I'm less impressed with his OO writing,
> largely because he does tend to see the world through the eyes
> of C++ and Java, both of which have a very singular view of OO
> which does not always work in other more dynamic OOP
> languages (Lisp, Smalltalk, Python, JavaScript etc)
I found his writing on principles of OO design very helpful when I was a
C++ programmer. I admit I have not revisited them from the point-of-view
of a Python programmer. I'm sure some of the techniques are not needed -
the pervasive use of interfaces, in particular - but the underlying
principles should still apply.
Taking a closer look, I think these still have something to offer:
The Liskov Substitution Principle
http://objectmentor.com/resources/articles/lsp.pdf
Inheritance vs. Delegation (Template Method and Strategy patterns)
http://objectmentor.com/resources/articles/inheritanceVsDelegation.pdf
The Craftsman series might be of interest.
One thing to keep in mind is that when C++ and Java use interfaces,
Python uses duck typing. C++ and Java use classes to encapsulate
functions (e.g. in Strategy) but Python can use functions directly.
Kent
More information about the Tutor
mailing list