Abstract Factory パターン
From Wikipedia, the free encyclopedia
Abstract Factory パターンのクラス図を以下に挙げる。

利用例
応用例
DOM は Abstract Factory パターンを応用した API の一つである。参考までに、クラス図との対応関係を示す。
- AbstractFactory
- org.w3c.dom.Document
- AbstractFactory#createProduct()
- org.w3c.dom.Document#createElement(String), org.w3c.dom.Document#createTextNode(String) など
- Product
- org.w3c.dom.Element, org.w3c.dom.Text など
関連するパターン
生成するProductを変更する手法としては、AbstractFactoryクラスがfactory method(Factory Method パターンを参照)を持ち、それを個々のConcreteFactoryが上書きする手法が一般的である。しかし、Prototype パターンを使い、prototypeとなるオブジェクトの変更により生成するProductを変える手法もある[1]。
ConcreteFactoryは、singletonオブジェクト(Singleton パターンを参照)であることもある。