Missing interfaces in Python...

C

Carl Banks

Ben said:
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
 
B

Ben

Oh I agree entirely. They are just equivalent ways of managing the
complexity of large projects.

I guess interfaces are "providing" specifications, and generics are
"receiving" specifications, so single dispatch methods can be identical
to interfaces only "inverted".

Therefore, as there is no interface equivalent of full multi-methods,
it shows that multimethods are the only primative you need to implement
all of the above

Cheers,
Ben
 
M

Michele Simionato

Carl said:
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. :)

+1 QOTW

Michele Simionato
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,282
Latest member
RoseannaBa

Latest Threads

Top