[PEAK] Interfaces

Terry Hancock hancock at anansispaceworks.com
Wed Jun 28 14:05:30 EDT 2006


Phillip J. Eby wrote:
>  The dir() function lists all the members of an interface, and the
>  'inspect' module offers plenty of features for inspecting method
>  signatures. If you want exact conformance, just compare the results
>  of inspect.getargspec() called on the source and target methods,
>  after removing the "self" argument from the target.

IOW, 'write the verifier myself'. I'll try this approach. Thanks very
much for the hints on how to do it with PyProtocols' interfaces.

I was a bit surprised that PP interfaces don't provide the
introspection/documentation methods that Zope interfaces do.

It bothers me that I have to filter the interface attributes from
the attributes of the interface object itself.  My first impression
is that this is going to create some red-herrings or
shadowing, but I'll have to think about that.

However, thank you, that was probably the answer I needed.

The rest is just philosophizing... ;-)

> > But that leaves a major gaping hole in my QA process. For me,
 >> one of the most important roles of interfaces is as testing tool
 >> to make sure that I really do have consistent interfaces
 >> between objects.
> > This has been a big time-saver on previous projects.
>
>  I'm frankly puzzled by this assertion, since it seems to imply that
>  people are declaring that they support interfaces without reading the
>  docs or implementing any unit or integration tests to prove it.

Well, two points:

1) I want the interface to *write* said documentation. (i.e. the
    interface should be the authoritative source).

2) It might be better to find out if the frog even has legs before
    asking if it can hop.  I find this saves considerable
    frog-building  and frog-testing time -- maybe your experience
    is different because you build snakes or millipedes, instead. ;-)

> > So, I'm starting to wonder if we're making a mistake by using
> > PyProtocols' interfaces.
>
>  Probably. But that's more because interfaces are a mistake in
>  general, even PyProtocols' lightweight implementation of the concept.
>  :) I've pretty much moved on to generic functions, which in
>  addition to being more general, also offer more potential (albeit a
>  largely unexplored potential at the moment) for semantic
>  verification. In a generic function, declaration and implementation
>  are the same thing -- you can't declare that you implement something
>  if you don't, because implementing something is the only way to
>  declare it.

Ah, 'you've passed on to a higher plane existence'. Okay.  Some of
us still find interfaces pretty useful. ;-)

Sounds interesting, but bleeding edge and possibly off the point
of what I'm doing (though I think it probably has other applications,
and hey, GvR approves, so it must be good, right?).  I will definitely
research it further, though.

Thanks again,
Terry

-- 
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com





More information about the PEAK mailing list