This pattern also referred as publisher – subscriber pattern describes a method to allow one object to be aware of another object changes.
It allows you to ask to be notified when the state of the observed object changes, so that you can react on that information.
As you can imagine, this pattern is widely used to implement event systems.
Have you ever write Ajax code or used a call back function?
Then you have used this pattern. Continue reading
As the name implies this pattern is used to create objects,
You can use it when you need to create an object without knowing the exact class, for example you want to create a Milk object but you don’t know if you need to create a ChocolateMilk or LowFatMilk classes. Continue reading
The singleton patterns was documented as a solution to a simple problem, “Only one object of class X can be instantiated at any time in the application”
Typically a singleton is implemented by restricting access to the class constructor, effectively making impossible to instantiate the class
It is common to use singletons for application wide configuration or database access classes.