简体   繁体   中英

Is it bad software architecture in C++ to create a wrapper class instead of designing from scratch?

I'm creating a 3D game engine on my own using OpenGL and the C++ (with the Boost Libraries). I guess it goes without saying that it is a LOT of work. To lighten the load, I have started to create wrapper classes for things in Boost that closely match my needs, instead of making the same classes from scratch. Also my naming scheme is very different from Boost and the STL so I felt at first that this kept things consistent throughout the codebase.

I am concerned that this practice is bad design technique. Is it OK to do that? What unforseen problems can arise, if any, from creating so many wrapper classes?

Nope it is completely harmless to use wrappers in most cases.

Usually your compiler shall unwind all the function calls and optimize out overhead of sourced libraries.

The slight problem would however be, if you use precompiled binaries, which would introduce some overhead.

To use wrappers in your case (meaning to keep your style convention, slight functionality changes, etc.) is completely OK practice.

ADD : Some of the "unforseen" stuff might be extra compile time, mess inside the code (U need to keep using those wrappers consistently...), or some extra functionality or behavior of the original class, that your wrapper does not support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM