The 'Gang of Four' Companion:

Factory Method Design Pattern

Formal specification of design patterns in LePUS3 and Class-Z

Print this document

This page is part of the The 'Gang of Four' Companion dedicated to the formal specification in LePUS3 and Class-Z of patterns from the 'Gang of Four' catalogue [Gamma et al 1995].



The Factory Method design motif

The informal description: Excerpts from [Gamma et al. 1995] (adapted for this purpose):

Intent: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

Structure: Original OMT diagram converted to UML (Why and How?):

Factory Method in UML


Collaborations: Creator relies on its subclasses to define the factory method so that it returns an instance of the appropriate ConcreteProduct.

Formal specification

See also:

Factory Method in LePUS3
Factory Method in LePUS3 (legend)
Factory Method in Class-Z (legend)