Design Patterns — A quick guide to Singleton pattern.

There is a very popular discussion on StackOverflow which provides really good justice justifying why one should be careful with this design pattern.Singleton patterns violate the single responsibility principle: by virtue of the fact that they control their own creation and lifecycle.They are generally used as a global instance which may lead to hidden dependencies in the code that could be exposed via interfaces.They inherently cause code to be tightly coupled.It is very difficult to adjust Singleton pattern in a multithreading environment and very easy to fall into race condition problems during initialization.For deeper understanding as to why this is considered anti-pattern, have a look in this site by Michael Safyan.Since we mentioned it above, the next blog will be a quick guide to the Facade design pattern..The Facade is not a creational pattern like Singleton and Abstract Factory but is classified as a structural design pattern..Don’t forget to like/clap my blog-post and follow my account..This is to give me the satisfaction that I helped some fellow developers and push me to keep on writing.Other quick-guides on design patterns:Design Patterns — A quick guide to Abstract Factory.. More details

Leave a Reply