design-patternsterminologyshim

What is the difference between the shim and facade/adapter patterns?


I'm developing an application that need to work with different incompatible versions of some library. My gut instinct was introducing an adapter between the app and the library that will have proper object of the library injected in it. Then, someone told me about shims. Not much literature is available about it.

I wanted to know how are shims different from facade and adapter design pattern? And what are some of the popular uses of the same?


Solution

  • In my eyes, an Adapter and a Shim would be the same.

    A Facade on the other hand serves a different purpose. If you expect your client code to need to be able to pull back the curtain, so to speak, and access the underlying library without using your object model, that would be a Facade. Facade presents a simplified or common set of objects/methods on top of a more complex system, but still provides access to the underlying complexities when additional behavior is required.

    The use of Adapter means your client code is completely, blissfully unaware of the underlying implementation details.