Factory Design

https://www.youtube.com/watch?v=ub0DXaeV6hA

http://www.newthinktank.com/2012/09/factory-design-pattern-tutorial/

What is factory design:

  1. When a method returns one of several possible classes that share a common super class
  2. The class is chosen at run time

When to use factory design:

  1. When you don't know ahead of time what class object you need
  2. When all of the potential classes are in the same subclass hierarchy
  3. To centralize class selection code
  4. When you don't want the user to know every subclass
  5. To encapsulate object creation

Decorator Design

What is decorator design pattern?

  1. Allow you to modify an object dynamically
  2. You would use it when you want the capabilities of inheritance with subclass, but you need to add functionalities at run time
  3. More flexible than inheritance
  4. Simplifies the code because you add functionalities using many simple cases
  5. Rather than rewrite old code, you can extend with new code

Singleton Design Pattern

results matching ""

    No results matching ""