- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 239字
- 2021-06-25 20:52:34
Abstract factory
The abstract factory is an extended version of the factory method. Instead of creating a single type of object, it is used to create a family of related objects. If the factory method had one AbstractProduct, the abstract factory has several AbstractProduct classes.
The factory method has an abstract method that is implemented by each concrete factory with the code to instantiate the abstract product. The abstract factory has one method for each abstract product.
If we take the abstract factory pattern and we apply it to a family containing a single object, then we have a factory method pattern. The factory method is just a particular case of the abstract factory.
The implementation of an abstract factory pattern is described in the following class diagram:

The abstract factory pattern is composed of the following classes:
- AbstractFactory: This is the abstract class that declares the methods that are creating types of products. It contains a method for each AbstractProduct that has to be created.
- ConcreteFactories: Concrete classes that implement the methods declared in the AbstractFactory base class. There is a factory for each set of concrete products.
- AbstractProducts: The base interfaces or classes for objects that are required. A family of related products is made up of similar products from each hierarchy: ProductA1 and ProductB1 are from the first family of classes, which is instantiated by ConcreteFactory1; the second family, ProductA2 and ProductB2, is instantiated by ConcreteFactory2.
- Access 數(shù)據(jù)庫應(yīng)用教程
- CentOS 7 Server Deployment Cookbook
- Android Development with Kotlin
- Machine Learning with R Cookbook(Second Edition)
- 面向STEM的Scratch創(chuàng)新課程
- 深度學(xué)習(xí):算法入門與Keras編程實(shí)踐
- CKA/CKAD應(yīng)試教程:從Docker到Kubernetes完全攻略
- 數(shù)據(jù)結(jié)構(gòu)(C語言)
- iOS應(yīng)用逆向工程(第2版)
- Mastering Google App Engine
- Mastering Python Networking
- Go并發(fā)編程實(shí)戰(zhàn)
- MATLAB GUI純代碼編寫從入門到實(shí)戰(zhàn)
- Mastering VMware vSphere Storage
- The Python Apprentice