Factory Design
https://www.youtube.com/watch?v=ub0DXaeV6hA
http://www.newthinktank.com/2012/09/factory-design-pattern-tutorial/
What is factory design:
- When a method returns one of several possible classes that share a common super class
- The class is chosen at run time
When to use factory design:
- When you don't know ahead of time what class object you need
- When all of the potential classes are in the same subclass hierarchy
- To centralize class selection code
- When you don't want the user to know every subclass
- To encapsulate object creation
Decorator Design
What is decorator design pattern?
- Allow you to modify an object dynamically
- You would use it when you want the capabilities of inheritance with subclass, but you need to add functionalities at run time
- More flexible than inheritance
- Simplifies the code because you add functionalities using many simple cases
- Rather than rewrite old code, you can extend with new code