I’ve seen multiple guys who are talking about MVC as a scalable solution for a web application. But I’ve got some questions about MVC. I’ve read on multiple sites that using static objects leads to procedural programming and not that’s far away from MVC.
Do you think is this true? If so, would using singleton patterns solve this problem?
I think Symfony2 has solved the issue quite elegantly. Instead of declaring static classes, it uses so-called “services” – there’s a central manager, which contains all the services and their configurations. In different parts of your code you could get the services from the container. The container always hands out the same instance of any class required (unless specified otherwise in the configuration), which means that the singleton pattern is hardly ever needed.
The official docs make a lot better job explaining it, so here’s the link about Symfony’s Service Container.
I bet other frameworks also use similar methods to get rid of having the need to use singletons.