Simplify Wrappers Right from the Start

As the preceding sections have shown, wrapping class hierarchies can be a work-intensive task. While it is sometimes necessary to wrap C++ classes so that you can override their virtual functions in managed classes, it is seldom useful to wrap all classes this way. Determining when a feature is really needed is key to simplifying your task.

You should also avoid reinventing the wheel. Before you wrap a library, make sure that the FCL does not already provide a class with the required features. The FCL often has more features than it seems. For example, the base class library already has a bunch of encryption algorithms. You can find them in the namespace System::Security::Cryptography. If the encryption algorithm you need is already implemented by the FCL, it is not necessary to wrap it again. If there is no implementation of the algorithm you want to wrap in the FCL, but the application is not strictly bound to the algorithm provided by the native API, it is typically preferable to use one of the standard algorithms provided by the FCL.

Was this article helpful?

0 0

Post a comment