C#设计模式--抽象工厂模式

C#设计模式教程(3):抽象工厂模式 抽象工厂模式是一种创建型设计模式,它提供了一个接口,用于创建一系列相关或相互依赖对象的家族,而无需指定它们具体的类。这种模式是工厂方法模式的一种扩展,它用于创建的不是一个产品,而是多个产品的家族。 阅读详情

0.C#设计模式-简单工厂模式

1.C#设计模式--工厂方法模式

设计模式:

抽象工厂模式(Abstract factory pattern)

在前几篇文章张分别介绍了工厂方法模式,简单工厂模式

简单工厂模式:

简单工厂模式的工厂类随着产品类的增加需要增加额外的代码

工厂方法模式:

工厂方法模式每个具体工厂类只完成单个实例的创建,所以它具有很好的可扩展性

但是在实际应用中,一个工厂不止会创建单一的产品,因为现在的工厂都多元化了,一个工厂创建一系列的产品,这就引入了抽象工厂的概念。

抽象工厂模式

抽象工厂模式是围绕一个超级工厂创建其他工厂。该超级工厂又称为其他工厂的工厂。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。在抽象工厂模式中,接口是负责创建一个相关对象的工厂,不需要显式指定它们的类。每个生成的工厂都能按照工厂模式提供对象。

实例:

下面以一个生产手机主要配件为例子,假设手机工厂需要生产手机屏幕和手机主板,俩条生产线,那么不同品牌的手机工厂生产出的屏幕和主板各不相同。

工厂方法模式类图:


抽象工厂模式C#代码举例:

AbstractFactory抽象工厂类

 

   /// <summary>
    /// 抽象工厂类:提供创建不同品牌的手机屏幕和手机主板
    /// </summary>
    public abstract class AbstractFactory
    {
        //工厂生产屏幕
        public abstract Screen CreateScreen();
        //工厂生产主板
        public abstract MotherBoard CreateMotherBoard();
    }


手机屏幕和主板基类


 

Screen手机屏幕类
    /// <summary>
    /// 屏幕抽象类:提供每一品牌的屏幕的继承
    /// </summary>
    public abstract class Screen
    {
        public abstract void print();
    }
MotherBoard手机主板类
    /// <summary>
    /// 主板抽象类:提供每一品牌的主板的继承
    /// </summary>
    public abstract class MotherBoard
    {
        public abstract void print();
    }

苹果手机屏幕和主板类



AppleScreen苹果手机屏幕类
    /// <summary>
    /// 苹果手机屏幕
    /// </summary>
    public class AppleScreen:Screen
    {
        public override void print()
        {
            Console.WriteLine("苹果手机屏幕!");
        }
    }
 AppleMotherBoard苹果手机主板类
    /// <summary>
    /// 苹果手机主板
    /// </summary>
    public class AppleMotherBoard:MotherBoard
    {
        public override void print()
        {
            Console.WriteLine("苹果手机主板!");
        }
    }

小米手机屏幕和主板类


XiaoMiScreen小米手机屏幕类
    /// <summary>
    /// 小米手机屏幕
    /// </summary>
    public class XiaoMiScreen:Screen
    {
        public override void print()
        {
            Console.WriteLine("小米手机屏幕!");
        }
    }
XiaoMiMotherBoard小米手机主板类
    /// <summary>
    /// 小米手机主板类
    /// </summary>
    public class XiaoMiMotherBoard :MotherBoard
    {
        public override void print()
        {
            Console.WriteLine("小米手机主板!");
        }
    }

苹果手机工厂类和小米手机工厂类


 

AppleFactory苹果手机工厂类
   /// <summary>
   /// 苹果手机工厂
   /// </summary>
    public class AppleFactory : AbstractFactory
    {
        /// <summary>
        /// 生产苹果手机屏幕
        /// </summary>
        /// <returns></returns>
        public override Screen CreateScreen()
        {
            return new AppleScreen();
        }

        /// <summary>
        /// 生产苹果手机主板
        /// </summary>
        /// <returns></returns>
        public override MotherBoard CreateMotherBoard()
        {
            return new AppleMotherBoard();
        }
    }
XiaoMi手机工厂类
    /// <summary>
    /// 小米手机工厂类
    /// </summary>
    public class XiaoMiFactory : AbstractFactory
    {
        /// <summary>
        /// 生产小米手机屏幕
        /// </summary>
        /// <returns></returns>
        public override Screen CreateScreen()
        {
            return new XiaoMiScreen();
        }

        /// <summary>
        /// 生产小米手机主板
        /// </summary>
        /// <returns></returns>
        public override MotherBoard CreateMotherBoard()
        {
            return new XiaoMiMotherBoard();
        }
    }

工厂测试类


 

    class Test
    {
        static void Main(string[] args)
        {
            //小米工厂生产小米手机的屏幕和主板
            AbstractFactory xiaomiFactory = new XiaoMiFactory();
            Screen xiaomiScreen = xiaomiFactory.CreateScreen();
            xiaomiScreen.print();
            MotherBoard xiaomiMotherBoard = xiaomiFactory.CreateMotherBoard();
            xiaomiMotherBoard.print();

            //苹果工厂生产苹果手机屏幕和主板
            AbstractFactory appleFactory = new AppleFactory();
            Screen appleScreen = appleFactory.CreateScreen();
            appleScreen.print();
            MotherBoard appleMotherBoard = appleFactory.CreateMotherBoard();
            appleMotherBoard.print();

            Console.Read();
        }
    }


运行结果:


 


源代码工程文件下载


 


李建忠 C#面向对象设计模式纵横谈(3):Abstract Factory 抽象工厂模式(创建型模式) C#面向对象设计模式纵横谈(3):Abstract Factory 抽象工厂模式(创建型模式) 立即下载

相关推荐

C#设计模式编程之抽象工厂模式新解

概述  在软件系统中,经常面临着“一系列相互依赖的对象”的创建工作;同时由于需求的变化,往往存在着更多系列对象的创建工作。如何应对这种变化?如何绕过常规的对象的创建方法(new),提供一种“封装机制”来避免客户程序和这种“多系列具体对象创建工作”的紧耦合?这就是我们要说的抽象工厂模式。   意图  提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类。  模型图  逻辑模型:  物理模型:  生活中的例子  抽象工厂的目的是要提供一个创建一系列相关或相互依赖对象的接口,而不需要指定它们具体的类。这种模式可以汽车制造厂所使用的金属冲压设备中找到。这种冲压设备可以制造汽车车身部件。同

C#设计模式——抽象工厂(Abstract Factory Pattern)

抽象工厂模式是一个创建型设计模式,本文讲解抽象工厂模式相关知识、抽象类和接口知识、C#中实现简单的抽象工厂模式,并展示扩展产品族和产品等级的情况。

qq_57198771的博客 2519

CentOS7无外网环境下MySQL8.0完整离线部署指南

本文详细介绍了在CentOS7无外网环境下,如何通过MySQL8.0二进制包进行完整离线部署。指南涵盖了从环境准备、依赖安装、用户与目录创建,到数据库初始化、服务配置及远程访问设置的全过程,并提供了关键的避坑技巧,帮助企业运维人员在内网环境中高效、稳定地搭建MySQL数据库服务。

xxx12的博客 1029

C#设计模式之---抽象工厂模式

抽象工厂模式(Abstract Factory Pattern)是一个超级工厂创建其他工厂。该超级工厂又称为其他工厂的工厂。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。工厂方法模式是为了克服简单工厂模式的缺点而设计出来的,简单工厂模式的工厂类着产品类的增加需要增加额外的代码,而工厂方法模式每个具体工厂类只完成单个实例的创建,它具有很好的可扩展性。

风清扬的专栏 946

【ESP32】1.编译、烧录、创建工程

本文介绍了在VSCode中搭建ESP32开发环境并烧录"Hello World"工程的过程。首先通过串口工具成功下载固件后,解决了OpenOCD报错问题。针对头文件无法识别的问题,修改了c_cpp_properties.json配置文件,调整了编译器路径和IntelliSense模式。文章还详细说明了创建新工程的步骤,包括选择芯片型号和项目模板,并验证了串口打印功能。最后提醒在项目构建时要等待完成,避免文件缺失。整个流程涵盖了环境搭建、代码烧录、调试及新项目创建等关键环节。

梁山1号 1486

深度学习之常用算子介绍

打开 onnx 模型图,可以看到它是一个有向无环图。除了 Input、Output ,其他都是算子(是操作,而不是节点)在ONNX(Open Neural Network Exchange)模型中,除了输入和输出,其他都是算子(Operations)。算子是表示神经网络模型中的不同操作或层的元素。一个ONNX模型由一系列算子组成,通过连接这些算子来定义模型的计算流程。

ueke1的博客 8463

C#设计模式——抽象工厂模式(重点)

【代码】C#设计模式——抽象工厂模式(重点)

weixin_42067536的博客 1075

别再踩坑了!CAPL脚本里局部变量和全局变量的那些“怪事”(附CANoe实测代码)

本文深度解析CAPL脚本中局部变量和全局变量的特殊机制,揭示其与通用编程语言的差异。通过实测代码展示静态局部变量的默认行为和全局变量的节点隔离特性,并提供高效避坑指南,帮助汽车网络测试工程师避免常见陷阱。

weixin_30225755的博客 294

C# 设计模式之抽象工厂模式

C# 设计模式之抽象工厂模式

鲤籽鲲的博客 1697

Uncaught ReferenceError: process is not defined

这个错误 Uncaught ReferenceError: process is not defined 通常出现在浏览器环境中,因为 process 是 Node.js 环境的内置对象,并不是浏览器原生支持的。因此,浏览器无法识别 process,导致该错误。在App.vue中加上以下代码就能够有效解决。

猿小白的博客 1744

T113-S3-RTL8211网口phy芯片调试

在嵌入式系统开发中,网络连接是至关重要的一部分。T113-S3开发板搭载了RTL8211系列的网口PHY芯片,用于实现以太网连接。在开发过程中,对于网口的稳定性和性能的调试至关重要。本篇博客将介绍如何调试T113-S3开发板中的RTL8211网口PHY芯片,以确保网络连接的正常工作。

flypig has a dream! 4615

C#设计模式(4)——抽象工厂模式

一、引言在上一专题中介绍了工厂方法模式,工厂方法模式是为了克服简单工厂模式的缺点而设计出来的,简单工厂模式的工厂类随着产品类的增加需要增加额外的代码),而工厂方法模式每个具体工厂类只完成单个实例的创建,所以它具有很好的可扩展性。但是在现实生活中,一个工厂只创建单个产品这样的例子很少,因为现在的工厂都多元化了,一个工厂创建一系列的产品,如果我们要设计这样的系统时,工厂方法模式显然在这里不适用,然后抽...

weixin_33863087的博客 669

利用dpabi和restplus提取ROI灰质体积学习笔记

目录前言一、数据准备二、利用dpabi提取ROI灰质体积三、restplus提取ROI灰质体积 前言 我利用SPM/CAT12进行灰质、白质、脑脊液分割之后分别已经得到各自的图像文件,在全脑水平已经做了统计分析。如果还想要进一步进行ROI的统计分析或者与量表等临床资料做相关分析,就需要提取ROI灰质体积。几个月没动过这数据了,突然心血来潮想学一下如何提取ROI灰质体积,以此篇博客记录我的提取ROI灰质体积学习过程。提取ROI灰质体积的方法及软件有许多种,本人尝试了dpabi和restplus。 一、数据准备

weixin_52073820的博客 9225

Abstract Factory Pattern 抽象工厂模式简介与 C# 示例【创建型】【设计模式来了】

一句话解释:通过对抽象类和抽象工厂的一组实现,独立出一系列新的操作,客户端无需了解其逻辑直接访问。抽象工厂模式(Abstract Factory Pattern)是一种创建型模式。它用于创建一组相关对象的家族。强调的是一组对象之间的协作关系,而不是单个对象之间的依赖关系。抽象工厂类负责创建整个家族的对象的生命周期,并隐藏与实现有关的逻辑。一个比喻:(科目与课代表)语文和数学的课代表和副课代表,都按照抽象方法标准选好了,接下来同样的通过实现抽象类和接口标准,来选出两名物理课代表。

woaimx_1314的博客 115

加速访问Cloudflare的网站的解决方案

本文主要介绍了加速访问Cloudflare的网站的解决方案,希望能对大家有所帮助。通过软件计算得到最快的IP地址的效果图如下图所示,具体解决方案参考下文。 在这里插入图片描述 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 1万+

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【C#设计模式(3)——抽象工厂模式(Abstract Factory Pattern)】

抽象工厂模式(Abstract Factory Pattern)

weixin_43626218的博客 1260

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C# 设计模式:第五章 - 创建者模式 之 抽象工厂模式(Abstract Factory Pattern)

在这章中,我们学习了抽象工厂模式的基本概念、应用场景、实现方法以及注意事项。抽象工厂模式提供了一种创建一组相关对象的接口,而不需要指定它们具体的类。它在创建相关对象的组合、支持多态性和提高代码的可扩展性方面有着重要的作用。我们通过两个实际的代码示例展示了如何在 C# 中实现抽象工厂模式,包括基本抽象工厂模式和家具制造系统。最后,我们还讨论了一些使用抽象工厂模式时需要注意的地方,帮助你在实际开发中做出明智的选择。

caifox的博客 1155

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Abstract Factory Pattern(抽象工厂模式)——《深入浅出设计模式(C#/Java版)》

来源:《深入浅出设计模式(C#/Java版)》 莫勇腾 编著哎,似乎越看越觉得糊涂了,先积累吧定义:  提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类。抽象工厂(Abstract Factory)模式又称为Kit模式,属于对象创建型模式。C#实例——大陆生态系统using System;namespace AnimalWorld{

bydxyj的专栏 1116

C#-设计模式-抽象工厂模式

这里首先以一个生活中抽象工厂的例子来实现一个抽象工厂,然后再给出抽象工厂的定义和UML图来帮助大家更好地掌握抽象工厂模式,同时大家在理解的时候,可以对照抽象工厂生活中例子的实现和它的定义来加深抽象工厂的UML图理解。抽象工厂模式:提供一个创建产品的接口来负责创建相关或依赖的对象,而不具体明确指定具体类抽象工厂允许客户使用抽象的接口来创建一组相关产品,而不需要知道或关心实际生产出的具体产品是什么。这样客户就可以从具体产品中被解耦。

Asincereman的专栏 1095

乐在其中设计模式(C#) - 抽象工厂模式(Abstract Factory Pattern)

乐在其中设计模式(C#) - 抽象工厂模式(Abstract Factory Pattern) 原文:乐在其中设计模式(C#) - 抽象工厂模式(Abstract Factory Pattern)[索引页] [源码下载] 乐在其中设计模式(C#) - 抽象工厂模式(Abstract Factory Pattern) 作者:...

weixin_30552635的博客 87

设计模式C#描述——抽象工厂模式

设计模式C#描述——抽象工厂模式 阅读此文应先阅读简单工厂模式与工厂方法模式 抽象工厂模式是对象的创建模式,它是工厂方法模式的进一步推广。 假设一个子系统需要一些产品对象,而这些产品又属于一个以上的产品等级结构。那么为了将消费这些产品对象的责任和创建这些产品对象的责任分开,可以引进抽象工厂模式。这样的话,消费产品的客户不需要直接参与产品的创建工作,而只需要向一个公用的工厂接口请求所需要的产品。 抽

深度Java 3016

C#设计模式——抽象工厂模式

1. 什么是抽象工厂模式 抽象工厂模式也是属于设计模式中的创建型模式,用于产品族的构建。 抽象工厂是指当有多个角色时使用的一种工厂模式。 抽象工厂模式可以向客户端提供一个接口,是客户端在不必指定产品的具体情况下,创建多个产品族的产品对象。 2. 抽象工厂模式的结构 图片来自:https://www.cnblogs.com/geq2020/p/12592104.html 3. 抽象工厂模式的应用场...

yanpingzaizai的博客 320
上一篇: C#设计模式--工厂方法模式
下一篇: C#设计模式--单例模式
JiYF
博客等级 码龄11年 356粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值