lundi 16 décembre 2019

Specifying interface for third-party implementors

I have a project that requires certain functions, and I have created an interface for these functions. If the implementations of the interface is to be performed by external parties, what should be the correct way to do this?

The idea I have is to create a class library project (MyInterface), define my interface (IModule) in this project, compile this and give the DLL (MyInterface.dll) to the external parties. The external parties would develop/implement using the DLL as a reference, then give me their final DLL. My main project would reference the MyInterface project, as well as all the implementations. In my code, I would do something like this:

IModule module = new ImplementationA();
module.DoSomething();
module = new ImplementationB(); // Change implementation at runtime

Is this approach correct? Are there better alternatives?

Side question: Is this strategy design pattern? Or facade?

Aucun commentaire:

Enregistrer un commentaire