What is a wrapper class?

8

What is a wrapper class?

How can they be useful?

Cite examples of usage at or

asked by anonymous 03.02.2014 / 16:58

1 answer

10

Wrapper are classes whose features they expose are implemented elsewhere.

It is common in C # for example to create wrappers classes to expose Win32 API features that are built into the .NET Framework through the functionality called PInvoke.

You may also have Wrappers that expose functionality from other libraries, and this happens a lot in PHP. An example is the phpGTK library that contains several classes wrappers from the native library.

It is recommended to use wrapper classes when you need to integrate functionality from external libraries / runtimes / languages that you are using as they provide you with a native interface to your language for the clients of your code. Also concentrating in one place only the possible maintenance that you will need to accomplish if a new version of the external library is incompatible with the integration that has been performed.

    
03.02.2014 / 17:09