全屏浏览
缩小浏览
回到页首

文章分类 -  设计模式

这里面记录的是设计模式
摘要:抽象工厂模式(Abstract Factory Pattern)是一种比较常用的模式,其定义如下:Provide an interface for creating families of related or dependent objects without specifying their c 阅读全文
posted @ 2018-04-21 09:52 huhx 阅读(628) 评论(0) 推荐(0)
摘要:模板方法的定义:Define the skeleton of an algorithm in an operation,deferring some steps to subclasses.TemplateMethod lets subclasses redefine certain steps o 阅读全文
posted @ 2018-04-21 09:38 huhx 阅读(600) 评论(0) 推荐(0)
摘要:享元模式(Flyweight Pattern)是池技术的重要实现方式,其定义如下:Use sharing tosupport large numbers of fine-grained objects efficiently.(使用共享对象可有效地支持大量的细粒度的对象。) 享元模式的使用 享元模式 阅读全文
posted @ 2018-04-18 20:14 huhx 阅读(886) 评论(0) 推荐(0)
摘要:桥梁模式(Bridge Pattern)也叫做桥接模式,是一个比较简单的模式,其定义如下:Decouple an abstraction from its implementation so that the two can vary independently.(将抽象和实现解耦,使得两者可以独立 阅读全文
posted @ 2018-04-18 20:09 huhx 阅读(346) 评论(0) 推荐(0)
摘要:适配器模式(Adapter Pattern)又叫做变压器模式,也叫做包装模式(Wrapper),但是包装模式可不止一个,还包括装饰模式。它的定义如下:Convert the interface of a class into another interface clients expect.Adap 阅读全文
posted @ 2018-04-18 20:07 huhx 阅读(451) 评论(0) 推荐(0)
摘要:命令模式是一个高内聚的模式,其定义为:Encapsulate a request as an object,thereby letting you parameterize clients with different requests,queue or log requests,and suppo 阅读全文
posted @ 2018-04-18 19:29 huhx 阅读(673) 评论(0) 推荐(0)
摘要:策略模式(Strategy Pattern)是一种比较简单的模式,也叫做政策模式(Policy Pattern)。其定义如下:Define a family of algorithms,encapsulate each one,and make them interchangeable.(定义一组算 阅读全文
posted @ 2018-01-04 16:22 huhx 阅读(659) 评论(0) 推荐(0)
摘要:装饰模式(Decorator Pattern)是一种比较常见的模式,其定义如下:Attach additionalresponsibilities to an object dynamically keeping the same interface.Decorators provide a fle 阅读全文
posted @ 2018-01-04 16:22 huhx 阅读(429) 评论(0) 推荐(0)
摘要:单例模式(Singleton Pattern)是一个比较简单的模式,它确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。今天我们就来学习一下单例模式的用法。有生之年,一起去看看这个美丽易碎的世界。凡有等待,就有启程。 单例模式 一、单例模式的通用代码 通过使用private的构造函数 阅读全文
posted @ 2017-12-26 11:53 huhx 阅读(554) 评论(0) 推荐(0)