Missing interfaces in Python...

Carl Banks invalidemail at aerojockey.com
Wed Apr 19 22:43:16 EDT 2006


Ben wrote:
> It seems to me that a lot of python projects reimplement interfaces or
> adaption of some kind once they reach a certain size (Zope, PEAK, eggs,
> TurboGears, etc), which implies that they really do have some benefits,
> particularly in documentation.

Yes.  On my current largish project I've noticed that, as I refactor
code and make it more and more concise, my classes have aquired pretty
mature interfaces.  I've begun thinking that a little inline tool to
check compliance would be helpful at this point.

However, all that refactoring I did to get my classes to that point
would have been much more tedious if I'd been using interface
definitions in early development; changing the interface definition
every time some new problem came up would have been a pain.  So I'm
leery of having them in the languge even if we're not forced to use
them.  I'm afraid people will start writing interface definitions
first, when they should be taking advantage of the duck typing to allow
easy design changes when necessary.  Only after a lot of effort, a lot
of refactoring, and a large part of the problem space explored, will
the interfaces be mature enough that writing interface definitions
would be useful and not a burden.  (And let's face it: there aren't
many projects that get that far. :)

Adaptation I have no comment about, not having needed it (yet).


Carl Banks




More information about the Python-list mailing list