I have been tasked with creating a library, which should be easily configurable and extendible by consuming clients.
suppose i have to create a library name testLibrary.. and it has three internal dependency.
class testLibrary {
private interfaceA a; //
private interfaceB b;
private interfaceC c;
constructor(interfaceA a, interfaceB b, interfaceC c){
initializes the class with default implementation of these interfaces.
}
}
here class C also depends on interfaceA , interfaceB
class C {
private interfaceA a;
private interfaceB b;
private interfaceD d;
constructor(interfaceA a, interfaceB b, interfaceD c){
//comes with a default implementation of interface A , B and D
}
}
Now if I am a client of class testLibrary and I want to use custom implementation of interfaceA and interfaceB inside this testLibrary, such that even internal dependencies of this library point to the custom ones if they depend on it.
What would be the best way to define this testLibrary so that its dependency can be easily pluggable ? Also Assume that as a client, i dont want to use any DI framework.
I would also be glad if people here can point me towards some good open source library which allow these kind of extensibility or pluggablity.
Aucun commentaire:
Enregistrer un commentaire