creating a wrapper around a 3rd party assembly - swap out and decouple
Posted
by mrblah
on Stack Overflow
See other posts from Stack Overflow
or by mrblah
Published on 2009-11-12T15:25:10Z
Indexed on
2010/03/11
17:19 UTC
Read the original article
Hit count: 320
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.
© Stack Overflow or respective owner