Victor STINNER wrote:
I'm thinking about global variables. We have to minimize their number.
Examples:
completely agree
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
extern ResourceManager resource_manager;
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
(somewhere else)
ResourceManager res;
...
InitWeapons(res); // void InitWeapons(ResourceManager &res);
...
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Why is it better? Because:
- We control when the object is create
- So we can manage dependancies (instead of having empty constructor and
then Init())
- We control when the object is destroyed
- So it's easier to manage memory
Yes, I have put a resource_manager global while I was nex to this
project and I would change less things as possible but a
resource_manager should be better instancied int the Application object
and then passed as argument when Init objects that rely on it
The problem is that the task is heavy and complicated, but it would be
cool to do that. I started with ... main menu.
We can start with the simpler cases as menus... and progressively made
it for all objects.
But before, what thinks the other about taht ? we can not choose alone..
a+
Jean-Christophe
--
Jean-Christophe Duberga - http://jeanchristophe.duber.free.fr
webmaster du site MNEA - http://www.mnea.fr