23种设计模式
Here are three short phrases to help remember the 23 design patterns, ordered by category:
Creational Patterns: "Abstract Building Factories Produce Stuff" (5 words)
Structural Patterns: "Adapted Bridges Connect Different Facades, Flyweight Proxy" (7 words)
Behavioral Patterns: "Caffeine Is Intoxicating; It Makes Others Stop, Stay, Struggle, Try, Visit." (11 words) 咖啡因是有毒的;它让其他人停下来、停留、挣扎、尝试、造访。
Note that these phrases are just one way to remember the patterns, and you may find it helpful to come up with your own mnemonic device or use another method to memorize them.
https://blog.csdn.net/daybreak1209/article/details/21986715
大家都说设计模式可根据目的划分为:
1、创建型(creational):主要用于处理对象的创建,实例化对象
2、结构型(structural):处理类或对象间的组合
3、行为型(behavioral):描述类或对象怎样进行交互和职责分配
但是让我疑问的是,为什么大家都约定俗成的把n个设计模式分门别类到这三个类别中去呢?分类的具体依据呢?创建型就真的用来创建对象?结构型就组合对象吗?它是怎么创建怎么组合的呢?
带着这些问题,笔者再度整理了一下思绪,提出几个特征明显的给您娓娓道来~至于针对每一类模式的进一步总结,敬请期待接下来的博文。
http://www.dofactory.com/net/design-patterns
序号 | CreationalPatterns创建模式 | 使用频率 | |
1 | Abstract Factory 抽象工厂模式 | 5 | Creates an instance of several families of classes |
2 | Builder 建造者模式 | 2 | Separates object construction from its representation |
3 | Factory Method 工厂方法模式 | 5 | Creates an instance of several derived classes |
4 | Prototype 原型模式 | 3 | A fully initialized instance to be copied or cloned |
5 | Singleton 单例模式 | 4 | A class of which only a single instance can exist |
Structural Patterns结构模式 | |||
6 | Adapter 适配器模式 | 4 | Match interfaces of different classes |
7 | Bridge 桥接模式 | 3 | Separates an object’s interface from its implementation |
8 | Composite 组合模式 | 4 | A tree structure of simple and composite objects |
9 | Decorator 装饰者模式 | 3 | Add responsibilities to objects dynamically |
10 | Facade 外观模式 | 5 | A single class that represents an entire subsystem |
11 | Flyweight 享元模式 | 1 | A fine-grained instance used for efficient sharing |
12 | Proxy 代理模式 | 4 | An object representing another object |
Behavioral Patterns行为模式 | |||
13 | Chain of Resp 责任链模式 | 2 | A way of passing a request between a chain of objects |
14 | Command 命令模式 | 4 | Encapsulate a command request as an object |
15 | Interpreter 解释器模式 | 1 | A way to include language elements in a program |
16 | Iterator 迭代器模式 | 5 | Sequentially access the elements of a collection |
17 | Mediator 中介者模式 | 2 | Defines simplified communication between classes |
18 | Memento 备忘录模式 | 1 | Capture and restore an object's internal state |
19 | Observer 观察者模式 | 5 | A way of notifying change to a number of classes |
20 | State 状态者模式 | 3 | Alter an object's behavior when its state changes |
21 | Strategy 策略者模式 | 4 | Encapsulates an algorithm inside a class |
22 | Template Method 模板方法模式 | 3 | Defer the exact steps of an algorithm to a subclass |
23 | Visitor 访问者模式 | 1 | Defines a new operation to a class without change |
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了