ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

Shim

Definition - What does Shim mean?

Shim, in C#, is a template class that is derived from a base class with derived classes that inherit the data and behavior of the base class and vary only in the type. The derived class of the shim class reuses the implementation provided by the shim class.

Shim can be designed to act as a thin compatibility layer, which can resolve the compatibility issues that may arise during the development of newer versions of applications. It is also used to execute applications on software platforms for which they were not originally designed.

In general, the shim class is mainly used to provide access to functionality only through the derived classes of the shim class. This approach helps provide code extensibility. It also prevents code duplication and avoids errors due to cut-and-paste. This can mean lower costs and less maintenance.

Techopedia explains Shim

A shim class is a template class that takes type as a parameter. It can be used at any level of an inheritance chain and can provide better maintenance and extension of the hierarchy.

A shim class can be implemented using containment and aggregation methods. In case of a containment approach, the shim class passes on its calls to the re-implementation of the interface to provide additional behavior. In the aggregation method, the interface to the inner class is passed to the outer object and there is no specialization of the behavior of the inner object.

For example, Wine is a shim that enables many Windows applications to execute on operating systems like Linux, Solaris, etc.

In cases where the call to unmanaged code needs to be forwarded from managed code after some initializations, shim class can be used as a wrapper class. This shim class can be created as a more generic class that cannot be used directly but allows for the generation of derived classes that have common functionality. It helps build a framework wherein the shim class forms the link between the base class that contains common functionalities and the derived classes that have customized functions.

A COM shim that links a Microsoft Office host application and managed extension helps provide security and isolates multiple Microsoft Office extensions.

This definition was written in the context of C#

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.