Hi
I've looked closer in the code and i see a lot of singletons ( ok not a lot but the some main components are singleton ). The evil part with this singletons is that singleton link very hard modules. The modules are not independent.
I can give you some examples : InputManager it is a singleton and ResourseManager it is a singleton.
So if i want to break the link between the other modules and InputManager or ResourseManager it will be impossible because this classes are link static ( using singleton ) . The module must work with other modules using interface . In this case it will be more easy to decouple modules . In this case we can change very easy the modules ( also at runtime ) and it will be easy to unit test each module ( because each module doesn't know the implementation of the module which work , it know only the interface of that module)
For example ResourseManager must be an interface . Every module that use ResourceManager must not know and must not be linked with the implementation of this interface . When we will unit test (using Junit) the module we will inject a mock ResourceManage used for that test.
An example . For example : I want to test a module that use a Sprite . In the actual coding the module it will ask the ResourceManager to get the sprite . The ResourceManager it will go to file and will read the sprite . But happening if i want to test my module in the case when the Sprite is not good( a parsing problem or an IOException ) . In this case it is impossible to test because my module it is link static to the resource manager. In normal case when i want to unit test ( Junit ) my case ( ResourceManager throw an IOException ) i will inject in my module a ResourceManager that throw every time an IOException .
A class that used ResourceManager must look something like this
class A{
private ResourceManager resourceManager;
public void setResourceManager(ResourceManager resourceManager){
this.resourceManager=resourceManager;
}
................... the class code
}
public interface ResourceManager{
}
So the module doesn't tried to find the the implementation of the REsourceManager , the ResourceManager implementation will be injected in the module.
This technique it is called "Inversion of control"
http://en.wikipedia.org/wiki/Inversion_of_ControlThe catch of this technique is that : it is very nice but who will inject my modules that i need in my module. this it will be done by a bottom layer that it is used to inject component.
What do you think ?
I look at the singleton i think i see a mistake . The method getInstance() must be synchronized . if it is not synchronized the Singleton are not thread safe . 2 thread can create 2 instance