
设计模式
nchangyu
这个作者很懒,什么都没留下…
展开
-
建造者模式
/// <summary> /// 食物条目 /// </summary> public interface Item { string name(); Packing packing(); float Price(); } public interface Packing{ string pack(); } ...原创 2019-12-13 15:18:14 · 108 阅读 · 0 评论 -
单例模式
饿汉式 优点:没有加锁,执行效率会提高。 缺点:类加载时就初始化,浪费内存。 public class SingletonPattern { public static SingletonPattern Instance=new SingletonPattern(); private SingletonPattern(){} pub...原创 2019-12-12 11:35:36 · 85 阅读 · 0 评论 -
适配器模式
/// <summary> /// 创建接口 /// </summary> public interface MediaPlayer { void Player(string audioType,string Filename); } public interface AdvancedMediaPlayer { void PlayerMP...原创 2019-12-12 10:41:35 · 88 阅读 · 0 评论 -
抽象工厂模式
//创建一个接口 public interface Shape { void draw(); } public interface Color { void fill(); } //创建实现接口的实体类 public class Rectangle :Shape { //@override public void draw(){ Report....原创 2019-12-10 14:22:42 · 96 阅读 · 0 评论 -
工厂模式
//创建一个接口 public interface Shape { void draw(); } //创建实现接口的实体类 public class Rectangle :Shape { //@override public void draw(){ Report.Info("Square::shape().menthod"); } } pub...原创 2019-12-10 10:56:37 · 114 阅读 · 0 评论