Design Patterns  «Prev 

Standard Names for Design Patterns

To some extent these names are not fixed.
For instance, the Abstract Factory pattern is also known as "Kit". Many other patterns have alternate names.
However, the names of the most common patterns are becoming de facto standards in the object-oriented community. Although names are to some extent arbitrary, nonetheless by agreeing on common names, programmers can communicate more easily and compactly. For example, if I need to explain the Java Cryptography API to a pattern-literate programmer, I simply say that
Cipher.getInstance()
is a Factory Method used to choose the right Template Method for the transformation. To explain the same thing to a non-pattern literate programmer would require me to spend several pages explaining the Factory and Template Method patterns.
This is similar in some respect to how a common set of data structures which all programmers are expected to know makes programs easier to explain, document, and understand.
There is no need to constantly re-explain the same reusable material.

Motivation

Modularization is a challenge in today's programming and for this reason developers are trying to avoid the idea of adding code to existing classes in order to make them support the encapsulation of more general information.
When using the Abstract Factory design pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).

The Abstract Factory Pattern

Intent

  1. Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
  2. The Abstract Factory pattern is very similar to the Factory Method pattern. One difference between the two is that ith the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation.
  3. Actually, the delegated object frequently uses factory methods to perform the instantiation.