Welcome Guest, Not a member yet? Register   Sign In
Dependency injection
#6

[eluser]TheFuzzy0ne[/eluser]
I see what your saying, but it seems a bit fruitless to me having a model (or any other object for that matter) loaded in the scope of the current function that you don't necessarily need to use. Personally, I think the issue should be addressed in the model loader. We should have the option to pass a model back by reference, or load into the CodeIgniter super object. If the model doesn't need to be available in the global scope, then we should be able to assign it to a class property instead.

Then, if we were to specify that we want the model passed back by reference, it should not be added to the instantiated models list, and should not be put into the CodeIgniter global scope. The loader should allow for multiple instantiations of the same object.

However, with that said, the model file itself should only need to be loaded once. Once it's loaded, you'd instantiate the class with the "new" keyword, so if anything, I feel that the model loader should allow us to specify whether or not we want the model instantiated in the global scope.

At the current time, the model loader assumes we want a model instantiated and globally accessible within the scope of the CI Super Object, but this may not always be the desired behaviour.


Messages In This Thread
Dependency injection - by El Forum - 03-27-2009, 04:35 AM
Dependency injection - by El Forum - 03-27-2009, 05:48 AM
Dependency injection - by El Forum - 03-27-2009, 06:03 AM
Dependency injection - by El Forum - 03-27-2009, 06:13 AM
Dependency injection - by El Forum - 03-27-2009, 07:45 AM
Dependency injection - by El Forum - 03-27-2009, 08:09 AM
Dependency injection - by El Forum - 03-27-2009, 08:13 AM
Dependency injection - by El Forum - 03-27-2009, 09:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB