Our code base uses several external libraries, in order to save time and focus on developing important features instead of reinventing the wheel.
Currently the code is littered with direct usage of the libraries. This means that switching to other libraries that have more-or-less the same features will mean rewriting almost everything from scratch. The ability to switch some of the libraries is important because of license issues and especially royalties.
Another important goal is to have better testing, currently writing unit tests and regression test is hard because of external dependencies (DLLs, licenses, etc.). A good wrapper will allow us to write mocks and stubs for library usage.
What are some best practices to use when wrapping the usage external libraries, so that it will be easier to replace them? Please consider the following when answering:
- I know that it's not possible to achieve 100% generic wrappers. It still doesn't mean we shouldn't do anything.
- The code and the libraries are Object Oriented, I didn't specify the exact language on purpose.
- How to deal with data passes back and forth between our code and the libraries. For example, should we mirror enumerations and constants?
- How can we minimize data conversion? For example, passing MyHashTable to an external function that accepts ExternalHashTable, or converting MyString to ExternalLibraryString.
- How to design our class hierarchies. Should we mirror the same class hierarchies from the libraries?
- How to deal with configuration methods? Some of the libraries are configured both in-code and in configuration files.
Please do not get too language specific. Code examples are OK as long as they don't feature a language-specific mechanism.