Dependency Injection & Singleton Design pattern
- by SysAdmin
How do we identify when to use dependency injection or singleton pattern.
I have read in lot of websites where they say "Use Dependency injection over singleton pattern". But I am not sure if I totally agree with them. For my small or medium scale projects I definitely see the use of singleton pattern straightforward.
For example Logger. I could use Logger.GetInstance().Log(...)
But, instead of this, why do I need to inject every class I create, with the logger's instance?.