为什么我们需要抽象工厂设计模式? [英] Why do we need Abstract factory design pattern?

查看:152
本文介绍了为什么我们需要抽象工厂设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数定义说:


一个抽象工厂提供一个
接口,用于创建
相关的家庭对象没有指定
他们的具体类

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:

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆