Phil Dennis
Posts: 2
Nickname: pdennis
Registered: Jan, 2005
|
|
Re: Clarification: Interfaces versus Abstract Classes
|
Posted: Jun 16, 2005 4:56 AM
|
|
> What was interesting to me in this discussion was the > point that came up about using interfaces in contrast to > having abstract classes and then their implementations in > subclasses. I totally get the point about not wanting to > break the clients. > > I had a little solid problem and this probably isn't the > best place to ask it. I should maybe post it in a java > forum. But since Micheal mentioned this point > > >"This matters only if the interface is intended to be > implemented by clients!" > > I thought he or someone else could elaborate on it.
I think the key point here is that all the implementations of an interface, are distributed alongside that interface, by the API owner. This means that the API owner can extend the interface, and also implement the new interface methods in all of the implementations.
Clients which simply "use" the interface, by making calls to the interface methods, will not be broken by the interface change, as would clients which implement the interface. Of course the API must provide a way of obtaining objects which implement the interface, either by having the implementations publically constructable, or by returning instances from methods on other accessible classes.
From the Eclipse example, clients should now call PlatformUI.getWorkbench().getHelpSystem() to obtain a reference to an implementation of the IWorkbenchHelpSystem, which they can then use, instead of calling the static function on the WorkBenchHelp class.
|
|