Abstract factory pattern
The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.
- Comment
- enThe abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.
- Depiction
- Has abstract
- enThe abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface. An example of this would be an abstract factory class DocumentCreator that provides interfaces to create a number of products (e.g., createLetter and createResume). The system would have any number of derived concrete versions of the DocumentCreator class like FancyDocumentCreator or ModernDocumentCreator, each with a different implementation of createLetter and createResume that would create a corresponding object like FancyLetter or ModernResume. Each of these products is derived from a simple abstract class like Letter or Resume of which the client is aware. The client code would get an appropriate instance of the DocumentCreator and call its factory methods. Each of the resulting objects would be created from the same DocumentCreator implementation and would share a common theme (they would all be fancy or modern objects). The client would only need to know how to handle the abstract Letter or Resume class, not the specific version that it got from the concrete factory. A factory is the location of a concrete class in the code at which objects are constructed. The intent in employing the pattern is to insulate the creation of objects from their usage and to create families of related objects without having to depend on their concrete classes. This allows for new derived types to be introduced with no change to the code that uses the base class. Use of this pattern makes it possible to interchange concrete implementations without changing the code that uses them, even at runtime. However, employment of this pattern, as with similar design patterns, may result in unnecessary complexity and extra work in the initial writing of code. Additionally, higher levels of separation and abstraction can result in systems that are more difficult to debug and maintain.
- Is primary topic of
- Abstract factory pattern
- Label
- enAbstract factory pattern
- Link from a Wikipage to an external page
- web.archive.org/web/20151101110755/http:/www.patterns.pl/abstractfactory.html
- designpattern.co.il/AbstractFactory.html
- web.archive.org/web/20080415015154/http:/www.lepus.org.uk/ref/companion/AbstractFactory.xml
- Link from a Wikipage to another Wikipage
- Abstract class
- Abstract interface
- Abstract type
- Base class
- Category:Articles with example C++ code
- Category:Articles with example Java code
- Category:Articles with example Python (programming language) code
- Category:Software design patterns
- Class (computer science)
- Class diagram
- Client (computing)
- Concrete class
- Data type
- Declaration (computer science)
- Design pattern (computer science)
- Design Patterns
- Encapsulation (computer programming)
- Factory method
- Factory method pattern
- Factory object
- File:Abstract factory UML.svg
- Header file
- Instance (computer science)
- Interface (object-oriented programming)
- Object (computer science)
- Object creation
- Operator (programming)
- Pointer (computer programming)
- Python (programming language)
- Run time (program lifecycle phase)
- Sequence diagram
- Singleton pattern
- Software design pattern
- Subtyping
- Unified Modeling Language
- SameAs
- 34kMj
- Abstract factory
- Abstract factory
- Abstract factory
- Abstract factory
- Abstract Factory
- Abstract Factory
- Abstract Factory
- Abstract factory pattern
- Abstract Factory パターン
- Abstrakte Fabrik
- Abstrakt fabrik
- Abstraktní továrna
- Absztrakt gyár programtervezési minta
- Fabrique abstraite
- Fabryka abstrakcyjna
- m.0bhpj
- Q333348
- Абстрактна Фабрика (шаблон)
- Абстрактна фабрика
- Абстрактная фабрика (шаблон проектирования)
- Апстрактна фабрика (пројектни узорак)
- Աբստրակտ ֆաբրիկա (նախագծման ձևանմուշ)
- الگوی کارخانه انتزاعی
- แบบโรงงานย่อ
- 抽象工厂
- 추상 팩토리 패턴
- Subject
- Category:Articles with example C++ code
- Category:Articles with example Java code
- Category:Articles with example Python (programming language) code
- Category:Software design patterns
- Thumbnail
- WasDerivedFrom
- Abstract factory pattern?oldid=1090754299&ns=0
- WikiPageLength
- 15762
- Wikipage page ID
- 41836
- Wikipage revision ID
- 1090754299
- WikiPageUsesTemplate
- Template:Commons-inline
- Template:Design Patterns Patterns
- Template:Plain image with caption
- Template:Reflist
- Template:See also
- Template:Wikibooks