Responsive Ads Here

Monday, July 29, 2013

Factory Pattern

Home

Factory Pattern

Intent

  • creates objects without exposing the instantiation logic to the client.
  • refers to the newly created object through a common interface

Implementation


Factory Implementation - UML Class Diagram







The implementation is really simple
  • The client needs a product, but instead of creating it directly using the new operator, it asks the factory object for a new product, providing the information about the type of object it needs.
  • The factory instantiates a new concrete product and then returns to the client the newly created product(casted to abstract product class).
  • The client uses the products as abstract products without being aware about their concrete implementation.

No comments:

Post a Comment