![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
文章平均质量分 87
孟凡勇
这个作者很懒,什么都没留下…
展开
-
设计模式之禅笔记——模板方法模式
一、模板方法模式的定义Define the skeleton of an algorithm in an operation,deferring some steps to subclasses,Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm'...原创 2018-06-26 23:36:59 · 190 阅读 · 0 评论 -
设计模式之禅笔记——责任链模式
一、责任链模式的定义定义如下:Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chai...原创 2018-08-12 17:07:38 · 229 阅读 · 1 评论 -
设计模式之禅笔记——原型模式
一、单例模式的定义定义如下:Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype(用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象)通用类图:通用代码:public class...原创 2018-08-12 12:09:07 · 206 阅读 · 0 评论 -
单例模式
一、单例模式的定义确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例通用类图:角色介绍:Client——高层客户端Singleton——单例类实现单例模式主要有如下几个关键点:(1)构造方法不对外开放,一般为private(2)通过一个静态方法或者枚举返回单例类对象(3)确保单例类的对象有且只有一个,尤其是在多线程下;(4)确保单例类对象在...原创 2018-08-11 22:50:07 · 210 阅读 · 0 评论 -
设计模式之禅笔记——工厂方法模式
一、工厂方法模式的定义Define an interface for creating an object,but let subclasses decide which class to instantiate,Factory Method lets a class defer instantiation to subclasses(定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂...原创 2018-07-31 08:03:04 · 167 阅读 · 0 评论 -
设计模式之禅笔记——装饰模式
一、装饰模式的定义装饰模式是一种比较常见的模式,其定义如下:Attach additional responsibilities to an object dynamically keeping the same interface.Decorators provide a flexible alternative to subclassing for extending functionalit...原创 2018-07-06 08:25:23 · 185 阅读 · 0 评论 -
设计模式之禅笔记——观察者模式
一、观察者模式的定义观察者模式也叫发布订阅模式,它是一个在项目中经常使用的模式,其定义如下:Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.(定义对象间一种一...原创 2018-06-28 22:58:42 · 300 阅读 · 0 评论 -
设计模式之禅笔记——状态模式
一、状态模式的定义Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.(当一个对象的状态改变时允许其改变行为,这个对象看起来像改变了其类)状态模式的核心是封装,状态的变更引起了行为的变更,从外部看来就好像这个对象对i...原创 2018-07-16 21:40:52 · 696 阅读 · 0 评论 -
设计模式之禅笔记——策略模式
一、策略模式的定义策略模式是一种比较简单的模式,也叫做政策模式,其定义如下:Define a family of algorithms,encapsulate each one ,and make them interchangeable.(定义一组算法,将每个算法都封装起来,并且使他们之间可以互换。)类图:策略模式使用的就是面向对象的继承和多态机制,非常容易理解和掌握,我们再来看看策略模式的三个...原创 2018-07-03 20:51:51 · 235 阅读 · 0 评论 -
设计模式之禅笔记——适配器模式
一、适配器模式的定义Convert the interface of a class into another interface clients expect.Adapter lets classes work together that couldn't otherwise bacause of incompatible interfaces.(将一个类的接口 变成客户端所期待的另外一个接口,...原创 2018-06-27 23:08:28 · 207 阅读 · 0 评论 -
设计模式之禅笔记——建造者模式
一、建造者模式的定义定义如下:Separate the construction of a complex object from its representation so that the same construction process can create different representations(将一个复杂对象的构建与它的表示相分离,使得同样的构建过程可以创建不同的表...原创 2018-08-12 20:05:18 · 227 阅读 · 1 评论