为什么我们需要抽象工厂设计模式? [英] Why do we need Abstract factory design pattern?
问题描述
大多数定义说:
一个抽象工厂提供一个
接口,用于创建
相关的家庭对象没有指定
他们的具体类
An abstract factory provides an interface for creating families of related objects without specifying their concrete classes
使用抽象工厂模式是什么,我们可以通过创建对象来实现任务具体类本身。为什么我们有一个创建Concrete类的对象的工厂方法?
What is the use of Abstract Factory Pattern as we can achieve the task via creating object of concrete class itself. Why do we have a factory method that creates object of Concrete class?
请提供我任何现实生活中的示例,我必须实现abstractFactory模式?
Please provide me any real life example where I must implement abstractFactory pattern?
推荐答案
抽象工厂是依赖注入(DI)的非常中心的设计模式。以下是抽象工厂应用被接受作为解决方案的Stack Overflow问题列表。
Abstract Factory is a very central design pattern for Dependency Injection (DI). Here's a list of Stack Overflow questions where application of Abstract Factory has been accepted as the solution.
根据我的理解,这些问题代表了人们的真正关切或问题,所以应该让你开始一些现实生活的例子:
To the best of my understanding, these questions represent real concerns or problems that people had, so that should get you started with some real-life examples:
- 是否有用于初始化通过a创建的对象的模式DI容器
- 不能组合工厂/ DI
- WCF依赖注入和抽象工厂
- 当关键类需要Session(或其他特定于上下文的变量)时,如何设置IoC
- 如何根据最终用户配置值来解析类型?
- 使用Unity的策略模式和依赖注入
- IoC顶部的抽象工厂模式
- 这是使用和测试类的正确方法使用工厂模式?
-
- DI容器,工厂或临时对象的新用户?
- 如何单元测试实例创建?
- 用户输入依赖注入的最佳策略是什么?
- Is there a pattern for initializing objects created via a DI container
- Can't combine Factory / DI
- WCF Dependency injection and abstract factory
- How to set up IoC when a key class needs Session (or other context-specific variable)
- How to Resolve type based on end-user configuration value?
- Strategy Pattern and Dependency Injection using Unity
- Abstract factory pattern on top of IoC?
- Is this the correct way to use and test a class that makes use of the factory pattern?
- DDD Book, Eric Evans: Please explain what is meant by "The FACTORY should be abstracted to the type desired rather than the concrete class(es) created."
- DI container, factory, or new for ephemeral objects?
- How to unit test instance creation?
- What is the best strategy for Dependency Injection of User Input?
这篇关于为什么我们需要抽象工厂设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!