设计模式
文章平均质量分 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 · 158 阅读 · 0 评论 -
状态模式在自动化中的应用
本文应用C#语言VS开发环境, 以实现自动咖啡机为例进行状态模式讲述 下图为手动冲泡咖啡的过程 传统思路,咖啡机可能处于不同的状态,所以会写一个状态变量记录,根据状态进行不同的动作,如下实现拿杯子动作 这样写有很多缺点 public class State { public string StateDesc = "当前状态名字"; public String MsgShow = "异常信息:"; public static bool原创 2021-07-16 12:58:49 · 228 阅读 · 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 · 75 阅读 · 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 · 72 阅读 · 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 · 84 阅读 · 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 · 96 阅读 · 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 · 301 阅读 · 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 · 101 阅读 · 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 · 121 阅读 · 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 · 106 阅读 · 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 · 127 阅读 · 0 评论 -
C#设计模式-结构型-适配器模式
适配器模式的实现要点: 在适配器模式的结构图有以下角色: (1)、目标角色(Target):定义Client使用的与特定领域相关的接口。 (2)、客户角色(Client):与符合Target接口的对象协同。 (3)、被适配角色(Adaptee):定义一个已经存在并已经使用的接口,这个接口需要适配。 (4)、适配器角色(Adapte) :适配器模式的核心。它将对被适配Adaptee角色已有的接口转换为目标角色Target匹配的接口。对Adaptee的接口与Target接口进行适配.转载 2020-06-16 15:07:20 · 162 阅读 · 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 · 84 阅读 · 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 · 124 阅读 · 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 · 316 阅读 · 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 · 96 阅读 · 0 评论 -
设计模式-简单工厂
简单工厂 优点:1 将对象创建者和对象使用者分开,降低耦合关系 2 无须修改主程序,可以在配置文件中修改参数 确定 :增加类数量,工厂扩展困难,增加产品工厂必须修改 ```csharp using 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 · 90 阅读 · 0 评论