[Python-3000] Abilities / Interfaces
Guido van Rossum
guido at python.org
Tue Nov 21 23:59:36 CET 2006
On 11/21/06, Andrew Koenig <ark-mlist at att.net> wrote:
> > In fact I'd be disappointed if some good deep
> > thinking about the ontology of interfaces wouldn't lead us to some
> > welcome changes to the specs.
>
> I don't know where this idea falls on the continuum between deep and silly,
> but...
>
> Suppose we stick for the moment with the notion that types (and objects of
> those types) can have abilities, and that those abilities are represented by
> other objects. So an object of type Foo might have ability Bar, and we
> would like to have some way of testing whether Foo has that ability. In
> other words, we would like a way to determine whether the author of Foo
> claims that Foo has ability Bar.
>
> Nothing new so far. But it just occurred to me that part of an ability
> (i.e. one of the methods of an ability) might be code that performs
> compliance tests on an object that claims to have that ability. This idea
> is very sketchy, but it suggests that perhaps abilities could be parking
> places for generic unit tests for interfaces, rather than tests of specific
> types or pieces of code.
I believe Ka-Ping once proposed something similar. This also jives
nicely with the "verify" functionality that I mentioned. However, I
don't know how easy it will be to write such compliance tests given
that typically the constructor signature is not part of the ability.
It may be more pragmatic to put the tests in a separate unit testing
module that can be subclassed by unit testing code for classes that
want specific claims to be verified.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list