Timeline for Dependency Injection Provider/Container
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 25, 2012 at 19:01 | comment | added | Anton | @orourkek If you feel the need to pass container at more than one place you are probably not using it the way it should be used. It only should be used at bootstrap logic. If you are passing it around because at some point in your code you have to create a class and you dont know its type beforehand you need to use a factory. Ideally you should write a factory and pass it to the class constructor that needs to create new instances of that class. All this gets wired only once - at bootstrap. It is okay to pass container to that factory in case you really need to, but you should still avoid it. | |
Oct 25, 2012 at 17:43 | comment | added | orourkek | I've now been using this in a few cases over the last couple of months, with some successes and failures; A few times I've had to stop myself from passing this object around freely - just as you mentioned - but overall it's been a great little class. I'm still a little worried about it being present in more places that it should, which gives some credence to your note about the service locator pattern. On the subject of the shared objects, the only class I've been sharing consistently is an input class (a wrapper for superglobals, with filtering capabilities), which is "global" by nature | |
S Oct 24, 2012 at 21:32 | review | Late answers | |||
Oct 24, 2012 at 21:54 | |||||
S Oct 24, 2012 at 21:32 | review | First posts | |||
Oct 25, 2012 at 2:17 | |||||
Oct 24, 2012 at 21:18 | history | edited | Anton | CC BY-SA 3.0 |
added 61 characters in body
|
Oct 24, 2012 at 21:12 | history | answered | Anton | CC BY-SA 3.0 |