Design Patterns: Abstract Factory (Kit)

Posted by Monik, 12 October 2010.
Programming Code Design Design Patterns
Book summary
Summary on basis of the book ,,Design Patterns: Elements of Reusable Object-Oriented Software'', by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Addison-Wesley, 1995.

class CertainFactory extends Factory{
@Override
ProductA createProductA(){
return new CertainProductA();
}
}
We do have an abstract Factory which defines an interface for instantiating object of general types. In implementing subclasses we instantiate objects as cetrain subtypes of the general types.

We can use such pattern for example for a toolkit that supports multiple look-and-feel standards. Each standard will then have corresponding Factory subclass, and for each widget type a set of specific classes. Clients have no knowledge even of the concrete widgets, just of the abstract Factory and general widget types.

We use it when we want to configure system with one of multiple families of product, and when we want to impose a constraint that objects specific for particular family should be used together; when we want to separate the system from its product creation, composition and representation; when we want to hide the implementation of products, i.e. when providing a class library;

Consequences and variations

Comments


Comments: