mardi 27 octobre 2015

Strategy for Wrapping external library return types

I have been asked to unit test some legacy code.

Currently, the code is tightly coupled with a 3rd party library both in terms of method calls and types used.

I am planning on writing a wrapper around the library in the form of a Façade design pattern which will aid in testability, create a cleaner interface for the rest of the code and allow me to swap out the library in the future if required.

This works fine where the method calls are void return type because the library functions are self contained. But what if the existing code uses library specific types? An example is here:

LibrarySpecificType[] myVar = wrappedLibrary.DoX();

Although I have wrapped my library call in the above example, it still returns a library specific type, so it is still somewhat coupled.

Does anybody know a way around this?

Aucun commentaire:

Enregistrer un commentaire