mercredi 27 juin 2018

Advantages and disadvantages of using one of Singleton or Dependency Injection over the other

I know the simple differences between them, but when it come to the scenario where I want to share an object instance in the app, I can done this by using DI or Singleton.

when this question come to my mind I became confused, since I can use both, I think that one of them must be better than the other in cases like multi-threading or memory management or code maintainability ...

can someone tell me what is the advantages and disadvantages of using one of them over the other in the above scenario and what is the correct choose ??

Aucun commentaire:

Enregistrer un commentaire