Glyph thinks that interfaces are great, and he is right (although I haven't read the full post, I certainly agree with the title).
One of the natural things you can do with interfaces is this: make a new class Bar that delegates all of the properties of IFoo to an instance of class Foo. This is the Decorator pattern (not to be confused with Python's decorator syntax), and is also the Bird in this parable.
We use interfaces a lot in Launchpad, and we need to Decorate classes quite a bit. So, we wrote something to make it easy and open sourced it. It's called lazr.delegates. This is Stone One, if you like.
Stone Two was actually cast first, and is called twisted.python.components.proxyForInterface. It's distributed as a part of Twisted, and solves exactly the same problem. For those interested, here's the Twisted implementation (scroll to line 320ish) and here's the lazr implementation.
Both implementations are fairly simple, and yet it is perhaps a shame that there are two of them. If anyone is at fault, it's me, since I knew about proxyForInterface and watched lazr.delegate arrive in the Launchpad tree without even thinking that the two might actually be the same thing.
But I wonder, is there a process bug here? Is there something Launchpad, Twisted, Zope or Guido could have done to avoid this?
Hacking, Software Collaboration, Testing and Diverse Other Topics of General Interest to the Practicing Programmer
Saturday, February 21, 2009
Subscribe to:
Post Comments (Atom)
Blog Archive
-
►
2010
(68)
-
►
November
(14)
- testtools manuals
- Tests that print stuff
- Boiling kettles, unit tests and data
- Big or small?
- "Don't Make Me Think", thoughts for Launchpad
- Reviewing specs, rock on!
- Having an extra feature never hurts, rebutted
- And then what?
- Make it really easy to fix bugs on Ubuntu
- What else have you got?
- Ubuntu in a VM on OS X?
- Still going
- What to do, what to do
- Launchpad and UDS-N
-
►
November
(14)
-
▼
2009
(56)
-
▼
February
(16)
- Fourteen Monthses
- Why you should have a public location for your bra...
- Betterer Cloud
- Useful, unpolished Bazaar plugin
- 100% Pure Doing
- Server reinstalled
- One bird, two stones
- Scheduled Unreliability
- Neat trick
- Things every project needs
- Everything I ever learned about programming...
- Better Cloud
- Make your code testable
- Bazaar commands
- Having said that, let me say this...
- Launchpad and Bazaar in South America
-
▼
February
(16)

1 comments:
I guess Twisted isn't the obvious place to look for interface utilities, or at least, it's not obvious to many people.
I guess you can relate this to the difficulty of spinning out useful things into separately distributed (maintained, released, installed, ...) packages.
Post a Comment