I using C++ to develop a software, and I am confused where to place the ProjectManager.
For example: the project have 4 more module. Each Module is organized by a set of head file and source file. The dependency graph shows like below:
higher level module depends on low level. ModuleBC and Other and depends on A. ModuleOther depends on BC.
ModuleOther
... |
... |
ModuleB ModuleC |
| | |
|-----------|-------|
|
ModuleA
The ModuleB and ModuleC have its Manager, ManagerB and ManagerC.
A Manager here is a class that deal with static resource init and finialize.
It should be init before using class in the module. It should be finalized after using.
For example: If we want using class B1 we must init ManagerB first and finialize ManagerB after use.
At this stage, I want a ProjectManager to manage ManagerB and ManagerC. It is used to manage the static resource in whole project. Init it is equal to init ManagerB and ManagerC.
ProjectManager::init()
{
ManagerB::init();
ManagerC::init();
}
My problem is where should place my ProjectManager? placed in Module A or B or C or any else? How to reduce the dependency?
The main function should be used something like follow
int main()
{
ProjectManager::init();
B1 b1;
b1.usingModuleB();
C1 c1;
c1.usingModuleC();
D1 d1;
d1.usingOtherModule();
...
ProjectManager::finialize();
}