Monday, February 10, 2014

Design Patterns

Software Design Patterns

A software design pattern is basically an abstract, general solution to a continuously recurring problem.
I will focus on describing the Factory Method design pattern.

Factory Method

 - Essentially the Factory Method defines an interface for creating objects, but lets the classes that implement this interface decide which class they are going to instantiate.

 - Basically, object creation is delegated to subclasses to:
       1)  Avoid code duplication
       2)  When creating an object requires access to information that should not be in the composing
class
     
- A problem with the Factory Method is that if it is not implemented right away, then refactoring existing code to use this pattern can be very time consuming and can break the code for a while.  As we all know, breaking the code should be minimal and basically non-existent in refactoring.

- The Factory Method is an excellent way to abstract the creation of objects to help the code be more modular.  It makes the code easy to change or to add new objects without changing the existing base of the code.

No comments:

Post a Comment