I have an email component that I am integrating into my application, looking for some tips on how should build a wrapper around it so I can swap it out with another 3rd party component if needed.
My approach right now is it:
- build an interface will the functionality I need.
- create a class that implements the interface, using my 3rd party component inside this class.
any usage of this component will be via the interface so like:
IPop3 pop3 = new AcmeIncePop3Wrapper(); pop3.connect();
and inside AcmeIncePop3Wrapper will be:
public void connect()
{
AcmeIncePop3 pop = new AcmeIncePop3();
pop.connect();
}
Is that a good approach?
I could probably add another abstraction by using ninject so I could swap out implementations, but really this seems to be all I need as i don't expect to be changing 3rd party assemblies every day, just don't want to make things so tightly coupled.