[Twisted-Python] twisted.positioning -- Interface, or class with method stubs?

Laurens Van Houtven lvh at laurensvh.be
Sun Aug 9 19:30:21 EDT 2009

Hash: SHA1

Hi :-)

As you probably know, the interfaces for t.p live in t.p.ipositioning.
I still haven't quite understood why they are going to be awesome, but
anyway -- I'm running into a problem where keeping them would (I
think) imply a bunch of duplicated code.

The thing is, t.p.nmea.NMEAAdapter needs to (at least, I think so)
implement all of the methods of t.p.ipositioning.IPositioningProvider,
because people will subclass t.p.nmea.NMEAAdapter and override the
corresponding (stub) methods. In order to get all of the stub methods
implemented (otherwise people using the class need to implement
*every* method, which is dumb, since a lot of people won't care about
things like GPS climb), I would basically be copying every line of the
body of the interface into the t.p.nmea.NMEAAdapter. This sounds like
a dumb idea.

Subclassing the interface sounds like *entirely* the wrong thing to
do, since the class is-not-an Interface.

Another alternative is using getattr-with-default-value in order to
call the methods, since then missing (non-implemented) methods will be
handled gracefully. I kinda like this one, mainly because it's very
little work ;-)

A third alternative would be to scrap the interface all together and
use a base class with method stubs (I'm deliberately not using the
word abstract there). This sounds like a bad idea because we'd be
losing the interface, but I'm not entirely sure why we want it in the
first place...

thanks for your time
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Use GnuPG with Firefox : http://getfiregpg.org (Version: 0.7.8)


More information about the Twisted-Python mailing list