Now the modules in my game engine are organized as namespaces. They have the functions Open () and Close (), which act similarly to the constructors and destructors of classes and are called when the game is entered to the left.
Examples of such modules are: a physical manager, an object manager, an I / O handler, and a rendering manager.
Now I'm starting to think that it is bad to have all the variables of the modules "lying" around and exported globally through the linker.
Refactoring modules from namespaces to classes will result in the following overhead:
There should be a global controller that allows you to interact between different modules, proving access to their instances
The interaction between the modules would get additional overhead for calling the function and 1-2 pointer markups
And the following benefits:
- RAII approval
- All state can be packed into one CState class, which contains instances of modules
- Good to make sure resources are removed and properly distributed.
My questions:
- Should I consider reorganizing my module modules from namespaces to managed classes? Why not)?
source
share