![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
会思考的猴子
这个作者很懒,什么都没留下…
展开
-
Unity 简单工厂模式
_Afra 的博客_会思考的猴子_CSDN博客-unity,Arduino,Processing领域博主 using UnityEngine; public class OperateTest : MonoBehaviour { private void Start() { // 实例化一个工厂对象 OperationFactory factory = new OperationFactory(); // 从工厂对...原创 2021-11-30 20:25:13 · 440 阅读 · 0 评论 -
设计模式--观察者模式(八)
1.0 双向耦合 using System; using System.Collections; using System.Collections.Generic; namespace Observer { class Program { static void Main(string[] args) { // 前台小姐...原创 2019-02-14 11:03:43 · 181 阅读 · 0 评论 -
设计模式--组合模式(十二)
1.0 using System; using System.Collections.Generic; namespace CompositeDesign { class Program { static void Main(string[] args) { Composite root = new Composite...原创 2019-02-19 16:45:53 · 182 阅读 · 0 评论 -
设计模式--迭代器模式(十三)
using System; using System.Collections.Generic; namespace IteratorDesign { class Program { static void Main(string[] args) { ConcreteAggregate a = new ConcreteAgg...原创 2019-02-19 17:31:25 · 123 阅读 · 0 评论 -
设计模式--桥接模式 ( 十四 )
桥接模式,主要利用(合成/聚合复用原则)比继承的耦合度会低 1.0 手机 与 软件 using System; namespace BridgeDesign { class Program { static void Main(string[] args) { MobileBrand ba = new BrandApp...原创 2019-02-19 21:28:05 · 124 阅读 · 0 评论 -
设计模式--命令模式 ( 十五 )
1.0 点菜 using System; using System.Collections.Generic; namespace CommandDesign { class Program { static void Main(string[] args) { // 开店前的准备 Barbecue...原创 2019-02-19 22:28:12 · 163 阅读 · 0 评论 -
设计模式--职责链模式 ( 十六 )
Chain Of Responsibility 1.0 处理请求示例 using System; namespace ChainOfResponsibility { class Program { static void Main(string[] args) { Console.WriteLine("Hello Wo...原创 2019-02-20 12:01:14 · 155 阅读 · 0 评论 -
设计模式--中介者模式 ( 十七 )
1.0 通话示例 using System; namespace MediatorDesign { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteL...原创 2019-02-20 13:50:28 · 178 阅读 · 0 评论 -
设计模式--享元模式 ( 十八 )
Flyweight c# string 调用的就是相同的示例,运用了享元模式 1.0 示例 using System; using System.Collections; namespace FlyweightDesign { class Program { static void Main(string[] args) { ...原创 2019-02-20 15:18:37 · 95 阅读 · 0 评论 -
设计模式--解释器模式 ( 十九)
Interpreter 1.0 using System; using System.Collections.Generic; namespace InterpreterDesign { class Program { static void Main(string[] args) { Context context...原创 2019-02-20 17:21:34 · 493 阅读 · 0 评论 -
设计模式--访问者模式 ( 二十)
1.0 using System; using System.Collections.Generic; namespace Visitor { class Program { static void Main(string[] args) { ObjectStructure o = new ObjectStructure...原创 2019-02-20 22:10:38 · 116 阅读 · 0 评论 -
设计模式--建造者模式(七)
1.0 using System; using System.Collections; using System.Collections.Generic; namespace BuilderDesign { /// <summary> /// 客户端类,客户不需要知道具体的建造过程 /// </summary> class Progra...原创 2019-02-13 17:12:16 · 185 阅读 · 0 评论 -
设计模式--外观模式(六)
1.0 using System; namespace FacadeDesign { class Program { static void Main(string[] args) { Facade facade = new Facade(); facade.MethodA(); ...原创 2019-02-13 16:21:34 · 144 阅读 · 0 评论 -
设计模式--备忘录模式(十一)
1.0 using System; namespace Memento { class Program { static void Main(string[] args) { Originator o = new Originator { State = "On" ...原创 2019-02-18 23:47:17 · 98 阅读 · 0 评论 -
Unity 依赖倒置原则
1.定义 高层模块不应该依赖低层模块,二者都应该依赖其抽象;抽象不应该依赖细节;细节应该依赖抽象。 以抽象为基础搭建起来的架构比以细节为基础搭建起来的架构要稳定的多。 抽象指的是接口或者抽象类,细节就是具体的实现类,使用接口或者抽象类的目的是制定好规范和契约,而不去涉 及任何具体的操作,把展现细节的任务交给他们的实现类去完成。 2.依赖倒置原则核心思想 依赖倒置原则的核心思想是面向接口...原创 2018-10-31 22:14:00 · 303 阅读 · 0 评论 -
Unity 隔离接口原则
定义 客户端不应该依赖它不需要的接口;一个类对另一个类的依赖应该建立在最小的接口上。 将臃肿的接口I拆分为独立的几个接口,类A和类C分别与他们需要的接口建立依赖关系。也就是采用接口隔离原则。 举例来说明接口隔离原则: using System.Collections; using System.Collections.Generic; using UnityEngine; public...原创 2018-10-31 23:51:08 · 377 阅读 · 0 评论 -
c# 简单工厂模式
封装 继承 多态 例子是模拟计算器 = - * / using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FactoryPattern { class Operation { ...原创 2018-11-07 12:56:27 · 198 阅读 · 0 评论 -
c# 策略模式
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class CashContext:MonoBehaviour { private void Start() { Context context; ...原创 2018-11-07 14:21:23 · 173 阅读 · 0 评论 -
设计模式--状态模式(九)
using System; namespace AbstractFactory { class Program { static void Main(string[] args) { Work work = new Work(); work.TaskFinished = true; ...原创 2019-02-17 23:04:31 · 100 阅读 · 0 评论 -
设计模式--代理模式(二)
1.0 不适用代理模式 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AgentModel { class Program { static void Ma...原创 2019-02-13 12:56:43 · 173 阅读 · 0 评论 -
设计模式--工厂模式(三)
1.0 雷锋工厂示例 using System; namespace FactoryDesign { class Program { static void Main(string[] args) { LeiFeng xueLeiFeng = new Undergraduate(); xueLei...原创 2019-02-13 13:46:25 · 133 阅读 · 0 评论 -
设计模式--原型模式(四)
1.0 using System; namespace PrototypeDesign { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); ConcretePrototype...原创 2019-02-13 14:50:45 · 113 阅读 · 0 评论 -
设计模式--模板方法模式(五)
1.0 例子 using System; namespace TemplateDesign { class Program { static void Main(string[] args) { Console.WriteLine("学生甲抄的试卷: "); TestPaper studentA ...原创 2019-02-13 15:53:31 · 119 阅读 · 0 评论 -
设计模式--适配器模式(十)
using System; namespace AdapterDesign { class Program { static void Main(string[] args) { Player b = new Forwards("巴蒂尔"); b.Attack(); Pla...原创 2019-02-18 22:35:14 · 102 阅读 · 0 评论 -
设计模式--观察者模式(一)
1.unity 目录结构如下: 2. canvas 下挂如下四个脚本 Subject.cs using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// <summary> /// 事件派发类,所有发生的事件都是由这个类...原创 2018-10-28 16:16:13 · 164 阅读 · 0 评论