I'm coding up a framework (in Java, but question is generic) in which I will provide a set of interfaces for clients to implement. The functions in the framework are going to rely on how the implementation classes will be constructued, that is, thay depend on those implementations to provide other instances of interfaces.
For example I might have:
Interface IContribution {
public IMyStuff getMyStuff();
public IHelper getHelper();
}
Interface IMyStuff {
public void doSomeMethod(IHelper helper);
}
How can I make sure that those instances of IMyStuff and IHelper are available?
One method would be to create the 'getter' methods in the interface and in my framework painstakingly check for null objects returned.
Another option would be to create abstract classes that implement a factory that calls (using a strategy patterns) the interface methods to be implemented. But this defies the fact that I have the interface in the first place. Clients should then use the abstract class. But they could circumvent this by using the interface instead of the abstract class. Therefore I should not provide the interface but only the abstract class...
So, what are your ideas on this, what is a pragmatic approach to this?