What is a wrapper class?

Asked

Viewed 5,272 times

11

What is a wrapper class?

How they can be useful?

Cite examples of use in or , as well as when to use or not to.

  • 2

    This question is not too general?

  • It’s literally one class that wraps another.

1 answer

13


Wrapper are classes whose features they expose are implemented elsewhere.

It is common in C# for example to create Wrappers classes to expose features of the Win32 API that are embedded in the Framework. NET through the functionality called Pinvoke.

You can 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 Wrapper classes from the native library.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.