设计模式笔记(9)---组合模式(结构型)

设计模式之结构型模式 结构型模式 一、适配器模式 (一)定义:适配器模式(Adapter Pattern)是作为两个不兼容的接口之间的桥梁,它结合了两个独立接口的功能。这种模式涉及到一个单一的类,该类负责加入独立的或不兼容的接口功能。 (二)应用实例:读卡器是作为内存卡和笔记本之间的适配器。您将内存卡插入读卡器,再将读卡器插入笔记本,这样就可以通过笔记本来读取内存卡。 (三)构成要素: 二、桥接模式 (一)定义:桥接模式是用于把抽象化与实现化解耦,使得二者可以独立变化,它通过提供抽象化和实现化之间的桥接结构,来实现二者的解耦。 阅读详情

Gof定义

将对象组合成树形结构以表示“部分--整体”的层次结构。Composite使得用户对单个对象和组合对象使用具有一致性。

在面向对象系统中,我们经常会遇到一类具有”容器“特征的对象---即他们在充当对象的同时,又是其他对象的容器。比如在一些管理系统中就会出现总公司下面有很多的分公司,分公司下面有很多的部门,每个部门下又有很多的员工,像分公司和部门就是既充当了“对象”的角色也充当了“容器”的角色;还有我们可能玩过的“俄罗斯套娃”也是这种结构,一个大娃娃里面装个小娃娃,小的里面又有个小的直到最小的一个,中间的娃娃就是既充当了“对象”也充当了“容器”。先看下面这个例子:

interface IBox
{
    void Process();
}
/// <summary>
/// 相当于树的叶子节点,没有子对象了
/// </summary>
public class SingleBox : IBox
{
    public void Process()
    { 
    
    }
}
/// <summary>
/// 容器
/// </summary>
public class ContainerBox : IBox
{
    List<IBox> list = new List<IBox>();
    public void Process() { }
    public List<IBox> GetBoxes()
    {
        return list;
    }
}
/// <summary>
/// 客户代码
/// </summary>
public class App
{
    static void Mina()
    {
        ///此处从工厂方法中得到盒子的对象,但我们不知道是SingleBox还是ContainerBox
        ///所以要做判断
        IBox box = Factory.Create();
        if (box is ContainerBox)
        {
            box.Process();
            List<IBox> list = ((ContainerBox)box).GetBoxes();
        }
        else if(box is SingleBox)
        {
            box.Process();
        }
    }
}

动机

上面代码的问题的根据在于:客户代码过多地依赖对象容器复杂的内部实现结构,对象容器内部实现结构(而非抽象接口)的变化将引起客户代码的频繁变化,带来了代码的维护性、扩展性等弊端。

如何将“客户代码与复杂的对象容器结构”解耦?让对象容器自己来实现自身的复杂结构,从而使得客户代码就像处理简单对象一样来处理复杂的对象容器?

这就要使用Composite模式了,先看下Composite模式的结构图

2009-11-24_073228

Component:定义了Leaf和Composite的一些共有特性。

Composite:有容器特征的类型。

Leaf:叶节点,即一个单独的个体,下面没有子节点。

依据上面的结构图完成代码实现:

public abstract class Component
{
    protected string _name;
    public Component(string name)
    {
        _name = name;
    }
    public abstract void Operation();
    public abstract void Add(Component component);
    public abstract void Remove(Component component);
}

public class Leaf : Component
{
    public Leaf(string name) : base(name) { }
    public override void Add(Component component)
    {
        throw new NotSupportedException();
    }
    public override void Remove(Component component)
    {
        throw new NotSupportedException();
    }

    public override void Operation()
    { 
        //...do something
    }
}

public class Composite : Component
{
    public Composite(string name):base(name){}
    List<Component> list = new List<Component>();
    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="conponent"></param>
    public override void Add(Component component)
    {
        if (list != null)
        {
            list = new List<Component>();
        }
        list.Add(component);
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="component"></param>
    public override void Remove(Component component)
    {
        if (list == null)
        {
            throw new NullReferenceException();
        }
        list.Remove(component);
    }

    public override void Operation()
    {
        if (list != null)
        {
            foreach (Component c in list)
            {
                c.Operation();
            }
        }
    }
}

Leaf类为叶子节点类,它的实例是没有子节点的,但是在抽象类中的方法Add和Remove方法必须要实现,按理说这样的实现是没有意义的,所以在此处抛出了NotSupportedException 异常,在客户端调用捕获到再做相应的处理,这种模式称之为“透明足组合模式”,这样做的好处是叶子(Leaf)和容器(Composite)对于外界没有分别,它们具有一致的接口行为。还有一种情况叫“安全组合模式”,在抽象类(Component)中不定义Add Remove方法,而是在容器的实现类中去定义,这样就各司其职了,看下面结构图

2009-11-24_232154

代码实现

public abstract class Component
{
    protected string _name;
    public Component(string name)
    {
        _name = name;
    }
    public abstract void Operation();
}

public class Leaf : Component
{
    public Leaf(string name) : base(name) { }

    public override void Operation()
    {
        //...do something
    }
}

public class Composite : Component
{
    public Composite(string name) : base(name) { }
    List<Component> list = new List<Component>();
    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="conponent"></param>
    public void Add(Component component)
    {
        if (list != null)
        {
            list = new List<Component>();
        }
        list.Add(component);
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="component"></param>
    public void Remove(Component component)
    {
        if (list == null)
        {
            throw new NullReferenceException();
        }
        list.Remove(component);
    }

    public override void Operation()
    {
        if (list != null)
        {
            foreach (Component c in list)
            {
                c.Operation();
            }
        }
    }
}

使用“安全组合模式”Leaf和Composite就不具有相同的接口,所以在客户端调用的时候还是要去判断是什么类型,比较麻烦。所以说选择哪种还要看具体的需求。

Composite模式的几个要点

Composite模式采用树形结构来实现普遍存在的对象容器,从而将“一对多”的关系转化为“一对一”的关系,使得客户代码可以一致地处理对象和对象容器,无需关心处理的是单个的对象还是组合的对象容器。

将“客户代码与复杂的对象容器结构”解耦是Composite模式的核心思>想,解耦之后,客户代码将与纯粹的抽象接口——而非对象容器的复内部实现结构——发生依赖关系,从而更能“应对变化”。

Composite模式中,是将“Add和Remove等和对象容器相关的方法”定义在“表示抽象对象的Component类”中,还是将其定义在“表示对象容器的Composite类”中,是一个关乎“透明性”和“安全性”的两难问题,需要仔细权衡。这里有可能违背面向对象的“单一职责原则”,但是对于这种特殊结构,这又是必须付出的代价。ASP.NET控件的实现在这方面为我们提供了一个很好的示范。

Composite模式在具体实现中,可以让父对象中的子对象反向追溯; 如果父对象有频繁的遍历需求,可使用缓存技巧来改善效率。

我终于停止写 JUnit 了!用 JavaParser + GPT-4 自动生成 90% 覆盖率的单元测试 本文介绍了一种基于JavaParser和GPT-4的智能单元测试生成方案。针对开发者在单元测试编写中面临的繁琐、无聊和硬指标等问题,提出通过AST语法树分析代码结构,提取关键信息后生成精准提示词,再调用GPT-4自动生成高质量的单元测试代码。文章详细阐述了技术原理、实现步骤(包括JavaParser解析、上下文感知提示词构建和GPT-4调用),并展示了该方法能自动识别依赖、Mock对象和覆盖边界条件,显著提升测试效率。同时指出了在复杂数据结构、私有方法测试等方面的局限性,最终强调这种技术组合可以解放开发者, 阅读详情

相关推荐

KANO分析模型

KANO分析模型的基本概念,目的意义,应用场景,实现方法和示例等

JasonH2021的博客 3066

纯CSS实现蜂窝六边形的个性相册

概述 纯CSS实现蜂窝六边形的个性相册 详细 代码下载:http://www.demodashi.com/demo/12804.html 此案例主要用到CSS3的 transform 和 transition属性,还有nth-child() 选择器 一、准备工作 1、主要运用到CSS3的3D transform变换   transform:向元素应用 2D 或 3D 转换。...

weixin_34179968的博客 1002

ESP32驱动TFT屏幕实战:LVGL与TFT_eSPI完美结合

本文详细介绍了如何在ESP32上结合TFT_eSPI驱动库与LVGL图形库,实现高效、流畅的嵌入式GUI开发。内容涵盖硬件连接、软件环境搭建、库配置、LVGL移植、界面创建及性能优化等全流程实战指南,帮助开发者快速构建低成本、高性能的交互式显示应用。

weixin_29206669的博客 200

设计模式学习笔记三:结构型模式(Structural Pattern)

声明:学习内容均来自《设计模式的艺术》这本书。

itman1010的博客 1658

从课堂笔记到动手实践:用Multisim仿真高频谐振功放(丙类)的完整流程

本文详细介绍了使用Multisim仿真高频谐振功放(丙类)的完整流程,从仿真环境准备到电路搭建、偏置网络设计、信号注入与波形观测,再到效率优化与性能验证。通过14个关键操作步骤,帮助读者将高频电子线路的理论知识转化为动手实践,深入理解丙类功放的非线性工作状态和效率优化技巧。

weixin_30701575的博客 520

电源完整性之Cadence Sigrity Power SI_AC阻抗仿真

之前和大家分享过电源完整性之仿真设计原理链接: [link](https://blog.csdn.net/weixin_41808082/article/details/117065140?spm=1001.2014.3001.5501).今天接着上一篇文章总结一下电源AC阻抗的的仿真操作流程及一些simulation中的设置参数,用到的时候Cadence Sigrity 中的Power SI组件,下面开始享受仿真的快乐吧: 1.仿真模式选择与文件导入 选择Cadence Sigrity下的Power SI

刘小同学的博客 1万+

设计模式学习笔记 --- 9.组合模式

组合模式(Composite Pattern),又叫部分整体模式,适用于把一组相似的对象当作一个单一的对戏那个。组合模式依据树形结构来组合对象,用来表述部分遗迹整体层次。这种类型的设计模式属于结构型模式,它创建了对象组的树形结构; 这种模式创建了一个包含自己对象组的类。该类提供了修改相同对象组的方式; 意图:将对象组合成树形结构以表示“部分-整体”的层次结构。组合模式使得用...

杨鑫newlife的专栏 516

uniapp(安卓苹果app端) - 微信小程序分享提示报错“由于不支持的分享类型无法分享到微信“,“由于应用和小程序未绑定在同意微信开放平台账号,无法分享到微信“解决办法,uniapp小程序分享失败

uni-app,安卓app,苹果app,手机app端,苹果ios,安卓Android,移动端app,分享,微信分享,微信朋友圈,微信好友,转发,vue2,vue3,App端调用手机的系统分享,微信小程序,分享功能,原生app分享小程序到微信,可分享到微信、朋友圈等,报错,uniapp分享报错由于不支持的分享类型无法分享到微信,未审核应用,uniApp安卓苹果app报错由于应用和小程序未绑定在同意微信开放平台账号,无法分享到微信,微信appid,已经配置了,还是报错,无法解决,一直提示,APP_ID错误,打包

✅ 精选推荐文章 5510

C#设计模式学习笔记:(9)组合模式

本笔记摘抄自:https://www.cnblogs.com/PatrickLiu/p/7743118.html,记录一下学习过程以备后续查用。 一、引言 今天我们要讲结构型设计模式的第四个模式–组合模式。当我们谈到这个模式的时候,有一个物件和这个模式很像,那就是“俄罗斯套娃”。“俄罗斯套娃”是 大的瓷器娃娃里面装着一个小的瓷器娃娃,小的瓷器娃娃里面再装着更小的瓷器娃娃,直到最后一个不能再装更小的瓷器娃娃的那个瓷器娃娃为止。在我们 的操作系统中有文件夹的概念,文件夹可以包含文件夹并可以嵌套多层,这个和“俄罗

chinaherolts2008的博客 343

【软件系统架构】系列六:系统工程

系统工程是一种跨学科方法论,用于分析、设计、集成和管理复杂系统的全生命周期。其核心特点包括系统性思维、全周期管理、跨学科协作和需求导向。主流采用V模型生命周期,涵盖需求分析、系统设计、实现、测试验证及运维退役等阶段。核心工作方法包括需求工程、系统建模、接口设计、风险管理等。系统工程与项目管理协同,分别侧重技术实现和进度资源管理。应用领域覆盖航天军工、智能制造、智慧城市等。未来将向AI融合、数字孪生、模型驱动工程等方向发展,为复杂系统开发提供系统化协作范式。

moton2017的博客 2257

海康视觉算法平台VisionMaster 4.3.0 C# 二次开发01 加载方案并获取结果

第一次使用海康视觉算法平台VisionMaster 4.3.0,项目中要使用这个平台进行视觉处理并获取结果。

StevenChen的博客 7875

设计模式学习笔记:组合模式(Composite)

文章目录一、组合模式简介二、组合模式的作用三、组合模式的应用四、示例演示组合模式结构图代码示例测试代码 努力才会收获成功,不努力只能永远羡慕别人。 一、组合模式简介 组合模式是设计模式中结构型模式的一种。它表示了一种将相似对象组合成树状结构的“部分-整体”的层次结构。组合模式使得用户对单个对象和组合对象的使用具有一致性。 二、组合模式的作用 组合模式的目的是:让客户端不再区分操作的是组合对象还是叶子对象,而是以一个统一的方式来操作。实现这个目标的关键之处,是设计一个抽象的组件类,让它可以代表组合对象和叶

爱辰 549

一般无穷积分的收敛判别法

文章目录积分里的狄屎判别法证明阿贝尔判别法总结补充:级数中的狄屎和Abel 积分里的狄屎判别法 F(u)=∫auf(x)dx在[a,+∞)F(u)=\int_a^uf(x)dx在[a,+\infty)F(u)=∫au​f(x)dx在[a,+∞)有界 x→+∞时,g(x)单减→0x\to+\infty时,g(x)单减\rightarrow0x→+∞时,g(x)单减→0 ⇒\Rightarrow⇒ ...

universe_1207的博客 1万+

备战面试日记(3.3) - (设计模式.23种设计模式之结构型模式)

本人本科毕业,21届毕业生,一年工作经验,简历专业技能如下,现根据简历,并根据所学知识复习准备面试。 记录日期:2022.1.9 大部分知识点只做大致介绍,具体内容根据推荐博文链接进行详细复习。 文章目录设计模式-23种设计模式之结构型模式设计模式分类设计模式介绍创建型模式结构型模式行为型模式结构型模式适配器模式引入概念对象适配器模型结构图示例代码类适配器模型结构图示例代码缺省适配器引入概念示例代码模式优点模式缺点使用场景最佳示例装饰器模式概念模型结构图示例代码模式优点模式缺点使用场景最佳示例JDK的I

weixin_44414492的博客 2330

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SAP B1中文培訓教材_SDK

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

2.设计模式_02_结构型设计模式

本文摘要主要介绍了GoF 23种设计模式的分类以及代理模式的实现方式。设计模式分为创建型(5种)、结构型(7种)和行为型(11种)三大类。重点阐述了代理模式的概念、应用场景及实现方式,包括静态代理和动态代理。静态代理部分详细说明了硬编码方案和继承方案的优缺点,并通过订单系统的案例展示了如何在不修改源代码的情况下通过代理模式实现性能监控功能。代理模式在需要保护目标对象、增强功能或复用代码时非常有用,是软件开发中常用的重要设计模式。

u011488477的博客 1255

efm32 入门.pdf

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

【学习笔记】设计模式-组合模式(Composite)

文章目录0 设计模式1 组合模式2 实现思路3 需要的类4 具体实现4.1 Node4.2 BranchNode4.3 LeafNode4.4 测试类5 思维导图6 示例源码地址最后 0 设计模式 不了解设计模式的小伙伴可以通过这篇文章了解一下什么是设计模式 https://blog.csdn.net/qq_42874315/article/details/120006447?spm=1001.2014.3001.5502 1 组合模式 组合模式,又叫部分整体模式,是用于把一组相似的对象当作一个单一的对象。

五条的博客 274

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

解锁结构型设计模式:架构师的必备秘籍

本文系统介绍了七种结构型设计模式及其应用。适配器模式通过接口转换实现不兼容类的协同工作;装饰器模式动态扩展对象功能;代理模式控制对象访问;外观模式简化复杂子系统调用;桥接模式分离抽象与实现;组合模式构建树形层次结构;享元模式共享细粒度对象以优化性能。文章通过具体代码示例展示了各模式的实现方式,并分析了实际应用场景,如电商系统、游戏开发、图形渲染等领域。最后指出,在人工智能、大数据等新兴技术背景下,结构型设计模式将持续发挥重要作用,并建议通过经典书籍、开源项目和实践来深入掌握这些模式。

大雨淅淅的博客 831

组合模式【Java设计模式】

组合模式【Java设计模式】

小心星的博客 283

《设计模式》学习笔记整理手册

文章目录一、GoF设计模式的分类1.1 创建型1.2 结构型1.3 行为型二、设计原则概述2.1 面向对象设计原则概述:2.2 单一职责原则2.3 开闭原则2.4 里氏代换原则2.5 依赖倒转原则2.6 接口隔离原则2.7 合成复用原则2.8 迪米特法则三、创建型设计模式3.1 抽象工厂模式3.1.1 模式定义3.1.2 模式角色3.1.3 简单例子3.1.4 抽象工厂模式和工厂模式的区别3.2 ...

Nicky's blog 4923

自学与复习设计模式笔记(9)组合模式

自学与复习设计模式笔记(9)组合模式

一木一白_ 194

【Java学习】Java设计模式——24种设计模式笔记整理

24种设计模式笔记整理,24种设计模式可以分为结构型模式、行为型模式和创造型模式

一棵灬大树的博客 2569

设计模式笔记--组合模式

设计模式笔记--组合模式

bihansheng2010的博客 7016
上一篇: 设计模式笔记(8)---桥接模式(结构型)
下一篇: 设计模式笔记(10)---装饰模式(结构型)
oec2003
博客等级 码龄20年 373粉丝 119原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值