So here is the deal. I managed to create a structure without using global or static classes / functions.
I use the dependency injection form using Factory. Since the framework will be used for different things, I create a more general Factory that will create your class with recursive relativistic dependencies.
The fact is that to save memory every time an object receives an instance, Factory stores a link to it, therefore, if another object has a dependency on this object, Factory will only need to return the link, Thus, we do not need to create an instance of one object twice.
This means that in many classes we will have many different references to the same object. For example, if I declare Blog_model, Blog_controller, Blog_view, Form_validation to require a Config object, each of them will be created with reference to the same Config object, albeit with an injection.
I am not familiar with unit testing or any automated testing. I just found that using global and statistics is bad (which is why I am rewriting the structure used). I want to ask if this introduces a global state? Does this interfere with testing in any way?
---- Update ------
This is an MVC framework written in PHP.
source
share