vendredi 30 septembre 2016

Example on how to use a container for DI?

I have read countless of posts about dependency injection and I really want to follow the "pure constructor way" of doing things. However I was thinking about the following and im not sure if its the right way:

  • Create a class that is a singleton and name it inject manager.
  • Manager has many private fields with all the instantiated dependencies.
  • dependencies can be called via getters.

Honestly I have no idea what to do. I want a technique can be used to set up a class that manages all my dependencies?

A simple example with explanation would be great. Im really interested in learning how this works. I heared its also possible with an interface but I couldnt find any examples.

Aucun commentaire:

Enregistrer un commentaire