Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Are the words "wrapper" and "shim" more or less synonymous, or is there a distinction, perhaps connotative?

share|improve this question

1 Answer 1

up vote 12 down vote accepted

A shim is typically something written specifically to maintain backwards compatibility. For example, if you have two versions of an API, version 1 and version 2, then rather than maintaining version 1 independently of version 2, you might write a shim that intercepts calls to version 1 of the API, translates the parameters to what version 2 requires, and then returns the results.

Typically, a shim is written by the provider of the API, rather than consumer.

A wrapper is written by the consumer of an API and is typically written so that you can switch the underlying API without the rest of your code having to know. For example, you might write a database wrapper so that you can talk to MS SQL Server, or Oracle, just by switching wrappers.

Of course, as with any terminology, there are gray areas, but I think the above covers the main differences.

share|improve this answer
1  
+1, the point about who writes it is a good way of explaining. –  Steve Haigh Apr 10 '11 at 20:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.