
设计模式
文章平均质量分 69
星河队长
上位机自动化 控制软件,视觉识别,软件算法
展开
-
设计模式-外观模式
外观模式把其他对象的方法统一到另外一个接口对象之内,调用一个方法进行using System;using System.Reflection;namespace FacadeSample{ class Program { static void Main(string[] args) { abstractFace ef; string FaceNamw= "FacadeSample.FaceSample原创 2020-06-28 18:55:37 · 200 阅读 · 0 评论 -
状态模式在自动化中的应用
本文应用C#语言VS开发环境,以实现自动咖啡机为例进行状态模式讲述下图为手动冲泡咖啡的过程传统思路,咖啡机可能处于不同的状态,所以会写一个状态变量记录,根据状态进行不同的动作,如下实现拿杯子动作这样写有很多缺点 public class State { public string StateDesc = "当前状态名字"; public String MsgShow = "异常信息:"; public static bool原创 2021-07-16 12:58:49 · 270 阅读 · 1 评论 -
设计模式--策略模式
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace StrategySample{ class Program { static void Main(string[] args) { Ticket mticket = new Tic..原创 2020-09-10 19:41:14 · 100 阅读 · 0 评论 -
设计模式-备忘录模式
备忘录模式是,缓存动作,把上一次动作内容记下来放在缓存中using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace MementoSample{ class Program { static void DisPlay(Pos pos) { C原创 2020-09-03 19:31:37 · 91 阅读 · 1 评论 -
设计模式-中介者模式
中介者模式,针对多个对象之间有相互交叉影响的关系,系统复杂耦合关系多的。为了降低耦合度,单独创建一个中介类,用来管理跟个模块之间的耦合关系。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace MediatorSample{ class Program { static vo原创 2020-09-02 20:14:24 · 105 阅读 · 0 评论 -
设计模式-解释器
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace InterpretSample{ class Program { static void Main(string[] args) {原创 2020-08-27 20:48:05 · 115 阅读 · 0 评论 -
C#命令模式
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication5{ class Program { static void Main(string[] args) { Start mstart = new St原创 2020-08-27 14:15:39 · 342 阅读 · 0 评论 -
设计模式-职责链
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace corSample2{ class Program { static void Main(string[] args) { AdAction action1, action2, act原创 2020-08-05 15:56:54 · 122 阅读 · 0 评论 -
设计模式-装饰者模式
装饰者模式用于串起来各个部分using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace DecorateSample{ //虚拟构件 abstract class VisualCompont { public abstract void DisPlay(); }原创 2020-06-18 16:56:43 · 146 阅读 · 0 评论 -
设计模式--组合模式
组合模式类似建造者模式using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace CompositSample{ abstract class AbstractFile { public abstract void Add(AbstractFile file); p原创 2020-06-18 15:23:27 · 138 阅读 · 0 评论 -
设计模式-桥接模式-结构性
桥接模式桥接模式和组合模式的区别,在于元素之间是嵌套关联的,如下例子中,图片类型中包含操作系统变量using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace AdapterSample{ //辅助像素矩阵类 class Matrix { // } //抽原创 2020-06-16 18:22:52 · 154 阅读 · 0 评论 -
C#设计模式-结构型-适配器模式
适配器模式的实现要点:在适配器模式的结构图有以下角色: (1)、目标角色(Target):定义Client使用的与特定领域相关的接口。 (2)、客户角色(Client):与符合Target接口的对象协同。 (3)、被适配角色(Adaptee):定义一个已经存在并已经使用的接口,这个接口需要适配。 (4)、适配器角色(Adapte) :适配器模式的核心。它将对被适配Adaptee角色已有的接口转换为目标角色Target匹配的接口。对Adaptee的接口与Target接口进行适配.转载 2020-06-16 15:07:20 · 193 阅读 · 0 评论 -
设计模式-单例模式
常规单例模式-简单的using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Clone{ class Program { abstract class property { public abstract property Clone()原创 2020-06-15 19:02:00 · 106 阅读 · 0 评论 -
设计模式-原型模式(克隆)
原型模式1 普通克隆using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Clone{ class Program { abstract class property { public abstract property Clone(原创 2020-06-15 18:34:18 · 158 阅读 · 0 评论 -
设计模式--建造者模式(组合模式)
建造者模式优点:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Configuration;using System.Reflection;namespace FactoryMothod{ //组合产品 class Compose { private原创 2020-06-15 16:23:46 · 358 阅读 · 0 评论 -
设计模式-抽象工厂
抽象工厂优点 1 比工厂方法的,一个工厂生产一个产品,优化为一个工厂生成多个产品using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Configuration;using System.Reflection;namespace FactoryMothod{ //抽象产品 in原创 2020-06-15 15:14:52 · 124 阅读 · 0 评论 -
设计模式-简单工厂
简单工厂优点:1 将对象创建者和对象使用者分开,降低耦合关系2 无须修改主程序,可以在配置文件中修改参数确定 :增加类数量,工厂扩展困难,增加产品工厂必须修改```csharpusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Configuration;namespace Factory原创 2020-06-15 13:50:40 · 112 阅读 · 0 评论