Extend Implements Concept and Fix Interface Method Names
Interface jargon and method renaming
Status: IsProposal
Author
Problem
We now have some standard jargon:
- Objects provide interfaces. If an object provides an interface, then the interface specifies (some) usage of the object.
- Classes implement interfaces. They are used to create objects that provide the interfaces that the classes implement. Instances of a class provide the interfaces implemented by the class.
Objects can provide interfaces directly, or they can provide interfaces indirectly through their classes.
Note that classes can also provide interfaces. The interfaces provided by a class specify behavior of the class, not it's instances.
I'd like to extend this jargon a bit. In particular, I'd like to extend the notion of implements to all factories. Not just to classes.
There are some interface methods, isImplementedBy, and
isImplementedByInstancesOf, that are no-longer consistent with
the jargon.
Proposal
Extend the meaning of implements to encompass all factories.
For example, if I create a factory function:
def createStuff():
...
I'd like to be able to declare that the factory implements the interfaces of the things it creates:
factoryImplements(createStuff, IStuff)
As far as renaming methods. I'd like to:
- Rename
isImplementedBytoprovidedBy.So, to ask whether an object provides an interface, you can use:
iface.providedBy(ob)This happens to be equivalent to:
providedBy(ob).extends(iface) - Rename
isImplementedByInstancesOftoimplementedBy.So, to ask whether a factory, such as a class, implements an interface, you can use:
iface.implementedBy(afactory)This happens to be equivalent to:
implementedBy(afactory).extends(iface)
Note that we will keep (but deprecate) the old names for a while for backward compatibility.
Why not "is" --jim, 2004/03/02 14:32 EST reply
A number of folks have asked my why I dropped "is" from the new method names. There are 3 reasons:
- We need to keep, but deprecate the old methods for a while for backward compatibility.
- Fewer words :)
- Symmetry. See the examples above.
