Dependency Injection & Singleton Design pattern

Posted by SysAdmin on Stack Overflow See other posts from Stack Overflow or by SysAdmin
Published on 2010-04-18T15:55:20Z Indexed on 2010/04/18 16:03 UTC
Read the original article Hit count: 218

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?.

© Stack Overflow or respective owner

Related posts about design-patterns

Related posts about dependency-injection