What is Shim?

What is the definition of Shim?

+106
terminology definition shim vocabulary
Jan 22 '10 at 9:11
source share
8 answers

From Wikipedia:

In computer programming, shim is a small library that transparently intercepts the API, changing the parameters passed, processes the process itself, or redirects the operation elsewhere. Gaskets typically occur when API behavior changes, thereby causing compatibility issues for older applications that still rely on older features. In these cases, the older API may still be supported by a thin layer of compatibility on top of the new code. Gaskets can also be used to run programs on different software platforms than they were designed for.

+77
Jan 22 '10 at 9:14
source share

The term “laying” as defined on Wikipedia will technically be classified based on its definition as a “structural” design pattern. Many types of "structural" design patterns are fairly clearly described in (for example, defacto) object-oriented software design patterns. "Design patterns, reusable item elements-Oriented software," better known as the "Gang of Four . "

The text “Gang of Four” contains at least 3 well-known templates known as “Proxies”, “Adapter” and “Facade”, which all provide the functionality of the “strip”. In most areas, the use and / or use of different abbreviations for the same root concept is often used, which leads to confusion of people. Using the word “gasket” to describe the more specific “structural” design patterns of “Proxy” , “Adapter” and “Facade” is certainly a prime example of this type of situation. Laying is simply a more general term for more specific types of “structural” proxy, adapter, facade, and possibly other patterns.

+65
Jul 04 '15 at 20:53 on
source share

As for the beginning of a word, the Google Dictionary dictionary widget

noun a washer or thin strip of material used to align parts, make them fit, or reduce wear. verb ( shimmed, shimming) [ trans. ] wedge (something) or fill up (a space) with a shim. ORIGIN early 18th cent.: of unknown origin 

This seems to be consistent with how web designers use the term.

+13
Jan 22 '10 at 9:15
source share

Encryption is used in the .net 4.5 Microsoft Fakes framework to isolate your application from other assemblies for unit testing . Ciphers redirect calls to specific methods for the code you write as part of your test

+11
Oct 20
source share

According to Microsoft's article "Shims Demystification" :

This is a metaphor based on the English word shim, which is a technical term used to describe a piece of wood or metal that is inserted between two objects so that they better fit together. In computer programming, a shell is a small library that transparently intercepts the API, changes the parameters passed, processes the operation itself, or redirects the operation to another location. Shims can also be used to run programs on different software platforms for which they were not designed.

I understand that this means that shim is a generic term for any code library that acts as an intermediary and partially or completely changes the behavior or operation of a program. As a real intermediary, he can influence the data transferred to this program, or influence the data returned from this program.

The article uses the Windows API as an example, and I found the following sentence relevant:

Typically, an application does not know that the request is being sent to the shim DLL, and not to Windows itself, and Windows does not know that the request comes from a source other than the application (because the shim DLL is just another DLL inside the application process). ,

To summarize this quote, two programs that make bread from a sandwich with a shim should not distinguish between communication with their program and conversation with a shim.

What are some of the pros and cons of using gaskets?

Again from the article:

You can fix applications without access to the source code or without changing them at all. You have minimal additional management overhead ... and this way you can fix a reasonable number of applications. The downside is support, as most vendors do not support shimming applications. You cannot fix every application using pads. Most people usually consider laying for applications where the vendor is not working, the software is not strategic enough to require support, or they just want to buy time.

In the context of this question, terms such as “proxy”, “adapter” and “facade” make more sense (at least for me) after reading the above link.

+10
Mar 21 '17 at 18:25
source share

Simple explanation through cartoon

Layout example:

My Dog Ralph is one lucky bash-tard (double pun intended)

Summary

A shim is some code that takes care of what was asked (by “intercepting”) and no one knows about it. This is a general concept. Please refer to the answers above for something more technical.

+9
Aug 02 '18 at 5:31
source share

As we have seen in many answers, PWM is a kind of adapter that provides API-level functionality that was not necessarily part of this API. There are many good and complete answers in this thread, so I will not expand the definition further.

However, I think I can add a good example that is Javascript ES5 Shim ( https://github.com/es-shims/es5-shim ):

Javascript has changed a lot over the last few years, and among many other changes to the language specification, many new methods have been added to its core objects.

For example, in the ES2015 specification (aka ES5), the find method was added to the Array prototype. Suppose you execute your code using the JavasScript engine before this specification (for example, Node 0.12), which this method does not yet offer. When you load the ES5 gasket, these new methods will be added to the Array prototype, which allows you to use them even if you are not using the newer JavaScript specification.

You may ask: why does someone do this instead of updating the environment to a newer version (say, Node 8)?

There are many real scenarios in which such an approach makes sense. One good example:

Suppose you have an outdated system that works in an old environment, and you need to use such new methods to implement / fix functionality. Updating your environment is still under development, as there are compatibility issues that require a lot of code changes and tests (a critical component).

In this example, you can try to create your own version of such functionality, but it will make your code more difficult to read, more complex, may lead to new errors and require tons of additional tests just to cover the functionality that, as you know will be available in a future release.

Instead, you can use this pad and use these new methods, using the fact that this fix / functionality will be compatible after the upgrade, as you are already using methods that are known to be available in the next specification. And there is an additional reason: since these methods are native to the specification of the next language, there is a high probability that they will work faster than any implementation that you could do if you tried to create your own version.

Another real-world scenario where this approach is welcome is at the browser level. Let's say you need support for an old browser and want to take advantage of these new features. Javascript is a language that allows you to add / change methods in its main objects (for example, add methods to the Array prototype), and these shim libraries are smart enough to add such methods only if they are not in the current implementation.

PS: 1) You will see the term "Polyfill" associated with these Javascript pads. Polyfill is a more specialized type of gasket that is used to provide direct compatibility across various browser-level specifications. By the way, my example above refers to just such an example.

2) Gaskets are not limited to this example (adding functionality that will be available in a future release). There are various use cases that are also considered gaskets.

3) If you are interested in how this particular polyfilm is implemented, you can open the Javascript Array.find specifications and scroll to the bottom of the page where you will find the canonical implementation for this method.

+3
May 2 '18 at 17:45
source share

SHIM is another layer of security verification that runs for all services to protect upstream systems. The SHIM server checks each incoming request with the user credentials of the headers for compliance with the user credentials that are transmitted in the request (SOAP / RESTFUL).

0
Dec 14 '18 at 5:07
source share



All Articles