[Grok-dev] questions about the Martian code
Brandon Craig Rhodes
brandon at rhodesmill.org
Thu Dec 18 22:53:07 EST 2008
Martijn Faassen <faassen at startifact.com> writes:
> Brandon Craig Rhodes wrote:
>> In the wake of that successful experiment, can I also remove the
>> GrokkerBase class itself? It looks like martian only uses
>> inheritance from that class to mark classes as implementing `IGrokker`...
> I'm on the fence. I think that'd be a bit more typing and perhaps
> slightly less clear when reading the code.
But it would mean that the interface declarations can then be read
inline, instead of being one level of indirection away where you have to
go look up the superclass to see that, "Oh, there's no functionality
there; it's just declaring implementation of an interface." :-)
> It's also safeguarding that any subclasses do implement 'grok', but
> that's probably not worth it as not subclassing would also safeguard.
I have attempted the removal on my local checkout, and all tests still
pass following its removal. It seems to me that the Zope Component
Architecture does something very powerful when it allows assertions
about what-something-does (interfaces) to become separate from
implementation details about what-something-is (its class and
superclass), and that we confuse that issue when we use inheritance to
mark classes as implementing certain functionality.
And, there already exist mechanisms to check a class for whether it
really implements the methods promised by an interface, without the Java
practice of creating an Abstract Base Class with a NotImplemented method
instead. GrokkerBase feels a little bit like an alien that has landed
from another planet - the planet Java, I mean, not Mars. :-)
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev