Ensures a class only has one instance and provide global point of access to it.
Example from Text Book:
The following example taken from “Heads First Design Pattern” book. 405 more words
Often times both of these patterns are confused one for other. Both are creational patterns and both creates object(s).
Factory Method creates an Object and defer instantiation to its subclasses. 178 more words
Composite objects are objects that contain other objects. A drawing may be composed of graphic primitives like circles, squares etc. Now we may want to say resize the circle or the rectangle which we can do individually, or we may want to resize the whole drawing itself. 161 more words
Today we will try to understand Strategy Pattern with the help of an example.
The example we will consider is The Game of Chess. The intention here is to explain strategy pattern and not to build a comprehensive Chess Game solution. 441 more words