0

Would this be considered dependency injection, or delegation or object collaboration?

https://gist.github.com/3428071

  • The page description says "dependency injection in php/codeigniter." – Robert Harvey Aug 22 '12 at 21:44
2

The ors in your question make it sound like those three things are mutually exclusive.

This is a form of dependency injection, albeit a non-conventional form of it. In the end, you are injecting Logger_model into User_model, so it is injection of a dependency. It is also true to say that Logger_model is a collaborator in this instance. And it is also true that User_model delegates logging to Logging_model.

So, basically, it's all of the above.

  • Thank you. I sat back and thought about the interaction of the classes some more and came to the same conclusion. However since you say this is a non-conventional form of it, would say using a Strategy Pattern where the User class instantiates the Logger depending on the action taken? What would be a more conventional form of DI? – Andre Dublin Aug 22 '12 at 22:46
  • @AndreDublin Have a read of this: theserverside.com/news/1321158/… – pdr Aug 22 '12 at 23:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.