I think everyone knows that globals are bad (if you’re reading this and don’t know why, you’re friend Google will fill you in), however less programmers seam to be aware of the fact that static methods and singletons are globalising your classes and methods. I’m sure everyone has used them as a convenient method of keeping a single instance of a class, especially for database classes, introducing the global factor is somewhat of an unwanted side effect.

For this reason LiteMVC will not contain any static methods or singletons and just a couple of global constants and a handful of class constants. The App class performs module loading and passes itself to the constructor of all modules as a form of dependency injection, allowing modules to interact with each other without the need for singletons and static methods.

Share