Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger


Saturday, November 5, 2011

Abstract Factory Design Pattern

Abstract Factory - Offers the interface for creating a family of related objects, without explicitly specifying their classes.

Thursday, November 3, 2011

Factory Method Common usage

Along with singleton pattern the factories are the most used patterns. Almost any application has some factories. Here are a some examples:
- factories providing an xml parser: javax.xml.parsers.DocumentBuilderFactory or javax.xml.parsers.SAXParserFactory 

Wednesday, November 2, 2011

Factory Method pattern When to use

Factory Method pattern should be used when:
- a framework delegate the creation of objects derived from a common superclass to the factory
- the base factory class does not know what concrete classes will be required to create - delegates to its subclasses the creation of concrete objects
- factory subclasses subclasses are aware of the concrete classes that must be instantiated

Factory method pattern, compared to Factory pattern replace the factory with an abstract class and a set of concrete factories subclasses. The subclasses are responsible for creating concrete product objects; for factory method is possible adding new product classes without changing the abstract factory. The same result can be achieved for simplified factory pattern if reflection is used.

Tuesday, November 1, 2011

Factory Method Design Pattern

Defines an interface for creating objects, but let subclasses to decide which class to instantiate and Refers to the newly created object through a common interface.