设计模式
yuanlong_zheng
这个作者很懒,什么都没留下…
展开
-
设计模式之09命令模式(笔记)
1 定义:1.1 定义:Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.(将一个请求封装成一个对象,从而让你使用不同的请求把客户端原创 2012-05-16 23:16:32 · 680 阅读 · 0 评论 -
设计模式之11装饰模式(笔记)
1 定义:1.1 定义:(Decorator Pattern)Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending functi原创 2012-05-16 23:25:35 · 663 阅读 · 0 评论 -
设计模式之12策略模式(笔记)
1 定义:1.1 定义:Define a family of algorithms, encapsulate each one, and make them interchangeable.(定义一组算法,将每个算法都封装起来,并且使它们之间可以互换)。1.2 通用类图:角色解说:Context封装角色:也叫上下文角色,屏蔽高层模块对策略、算法的直接访问,封装可能的变化原创 2012-05-16 23:31:58 · 959 阅读 · 0 评论 -
Android设计模式系列
Android设计模式系列http://www.cnblogs.com/qianxudetianxia/tag/Android%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E7%B3%BB%E5%88%97/转载 2012-05-19 11:12:34 · 699 阅读 · 0 评论 -
设计模式之14迭代器模式(笔记)
1 定义:1.1 定义:Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.(它提供一种方法访问一个容器对象中各个元素,而又不暴露该对象的内部细节。)此模式是一个没落的模式,基本上没人会单独写一个迭代器模原创 2012-05-20 14:37:16 · 671 阅读 · 0 评论 -
设计模式之15组合模式(笔记)
1 定义:1.1 定义:Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.(将对象组合成树形结构以表示“部分-整体”的层次结构原创 2012-05-20 14:45:11 · 704 阅读 · 0 评论 -
设计模式之16观察者模式(笔记)
1 定义:Observer Pattern,也叫做发布订阅模式(Publish / subscribe)1.1 定义:Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automati原创 2012-05-20 14:51:23 · 986 阅读 · 0 评论 -
设计模式之18备忘录模式(笔记)
1 定义:1.1 定义:Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later. (在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将原创 2012-05-20 15:10:11 · 888 阅读 · 0 评论 -
设计模式之19访问者模式(笔记)
1 定义:1.1 定义:Represent an operation to be performed on the elements of an object structure. Vistor lets you define a new operation without changing the classes of the elements on which it operates.原创 2012-05-20 15:16:04 · 1806 阅读 · 0 评论 -
设计模式之20状态模式(笔记)
1 定义:1.1 定义:Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.(当一个对象内在状态改变时允许其改变行为,这个对象看起来像改变了其类)。1.2 通用类图:一个更易理解的类图:角色解说:原创 2012-05-20 15:18:44 · 889 阅读 · 0 评论 -
设计模式之21解释器模式(笔记)
1 定义:1.1 定义:Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.(给定一门语言,定义它的方法的一种表示,并定义一个解释器,该解释器使原创 2012-05-20 15:22:44 · 922 阅读 · 0 评论 -
设计模式之23桥梁模式(笔记)
1 定义:1.1 定义:Decouple an abstraction from its implementation so that two can vary independently.(将抽象和实现解耦,使得两者独立地变化。)1.2 通用类图:1.3 通用代码:public interface Implementor { // 基本方法 public void d原创 2012-05-20 15:31:37 · 1113 阅读 · 0 评论 -
设计模式之22享元模式(笔记)
1 定义:1.1 定义:Use sharing to support large numbers of fine-grained objects efficiently.(使用共享对象可以有效地支持大量的细粒度的对象。)细粒度对象:不可避免地使得对象数量多且性质相近,可将这些对象的信息分为两个部分:内部状态(intrinsic)与外部状态(extrinsic)。内部状态:对象可共享原创 2012-05-20 15:26:33 · 1293 阅读 · 0 评论 -
设计模式之17门面模式(笔记)
1 定义:1.1 定义:(Façade Pattern)Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.(要求一个子系统的外部与其内部的通信必须通过原创 2012-05-20 14:59:44 · 1485 阅读 · 0 评论 -
读<设计模式之禅>之前言
0.设计模式是什么?它是一套理论,由软件界的先辈们总结出的一套可以反复使用的经验,它可以提高代码的可重用性,增强系统的可维护性,以及解决一系列的复杂问题。(软件的难处是如何把握需求的变更,变更不可控,只能拥抱变化)。设计模式给出了指导,专家首先提出了6大设计原则。设计模式是对面向对象思想的深刻理解,对软件设计方法和编码经验的完美总结。但“6大原则”——口号,而“23种设原创 2012-04-03 09:14:13 · 905 阅读 · 0 评论 -
设计模式之06代理模式(笔记)
1 定义:1.1 定义:Provide asurrogate or placeholder for another object to control access to it.(为其他对象提供一种代理以控制对这个对象的访问)。1.2 通用类图:1.3 通用代码:代理模式也叫做委托模式,它是一项基本设计技巧。许多其它的模式,如状态模式、策略模式、访问者模式本质上是在原创 2012-05-16 22:54:55 · 1201 阅读 · 1 评论 -
设计模式之10责任链模式(笔记)
1 定义:1.1 定义: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 chain u原创 2012-05-16 23:21:49 · 709 阅读 · 0 评论 -
六大原则之“迪米特法则(LoD)“笔记
1.迪米特法则:Law of Demeter, LoD),也称最少知识原则(Least Knowledge Principle, LKP)定义:Only talk to your immedate friends.(只与直接的朋友通信)。一个对象应该对其他对象有最少的了解。(通俗地讲,一个类应该对自己需要耦合或调用的类知道得最少)2.理解:2.1 只和朋友交原创 2012-04-10 06:41:13 · 4851 阅读 · 4 评论 -
23个经典JDK设计模式
转自:http://coolshell.cn/articles/3320.html下面是JDK中有关23个经典设计模式的示例,在stakeoverflow也有相应的讨论:http://stackoverflow.com/questions/1673841/examples-of-gof-design-patternsStructural(结构模式)Adapter:转载 2012-05-10 10:10:00 · 855 阅读 · 0 评论 -
六大原则之“开闭原则(OCP)“笔记
1.开闭原则:Open Closed Principle, OCP)定义:Software entities like classes, modules and functions should be open for extension but closed for modifications.(一个软件实体如类,模块和函数应该对扩展开放,对修改关闭。)2.理原创 2012-05-14 10:19:19 · 4431 阅读 · 3 评论 -
六大原则之“依赖倒置原则(DIP)“笔记
1. 依赖倒置原则,(Dependence Inversion Principle, DIP )定义:High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. D原创 2012-04-08 14:57:47 · 2185 阅读 · 1 评论 -
六大原则之“接口隔离原则(ISP)“笔记
1.接口隔离原则:(Interface Segregation Principle, ISP)定义:Clients should not be forced to depend upon interfaces that they don't use.(客户端不应该依赖它不需要的接口)。或 The dependcy of one class to another one should原创 2012-04-09 05:33:30 · 2995 阅读 · 0 评论 -
六大原则之“里氏替代原则(LSP)“笔记
1. 里氏替代原则,(Liskov Substitution Principle, LSP )定义:Functions that use pointers or referrnces to base classes must be able to use objects of derived classes without knowing it.(所有引用基类的地方必须能透明地使用其子类的原创 2012-04-04 22:05:27 · 6320 阅读 · 0 评论 -
设计模式之02工厂方法模式(笔记)
1 定义:1.1 定义:Define aninterface for creating an object, but let subclasses decide which class toinstantiate. Factory Method lets a class defer instantiation to subclasses.(定义一个用创建对象的接口,让子类决定实例化哪一个类。工原创 2012-05-14 16:17:29 · 967 阅读 · 0 评论 -
设计模式之03抽象工厂模式(笔记)
1 定义:1.1 定义:抽象工厂模式(AbstractFactory Pattern)Provide an interface ofr creating families of related or dependentobjects without specifying their concrete class.(为创建一组相关或相互依赖的对象提供一个接口,而且无需指定它们的具体类。) 1原创 2012-05-14 19:30:09 · 1057 阅读 · 0 评论 -
设计模式之04模板方法模式(笔记)
1 定义:1.1 定义:Define the skeleton of an algorithm in anoperation, deferring some steps to subclasses. Template Method lets subclassesredefine certain steps of an algorithm without changing the algor原创 2012-05-14 20:54:31 · 713 阅读 · 0 评论 -
设计模式之05构建者模式(笔记)
1 定义:1.1 定义:Separate theconstruction of a complex object from its representation so that the sameconstruction process can create different representations.(将一个复杂对象的构建与它的表示分离,使用同样的构建过程可以创建不同的表示。)1.原创 2012-05-15 10:45:32 · 944 阅读 · 2 评论 -
设计模式之01单例模式(笔记)
1 定义:1.1文字定义:Ensure a classhas only one instance, and provide a global point of access to it.(确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。)1.2通用类图:图1 单例模式通用类图1.3通用代码:public class Singleton {原创 2012-05-14 11:48:06 · 1740 阅读 · 3 评论 -
设计模式之13适配器模式(笔记)
1 定义:1.1 定义:Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. (将一个类的接口变换成客户端所期待的另原创 2012-05-16 23:35:09 · 645 阅读 · 0 评论 -
设计模式之07原型模式(笔记)
1 定义:1.1 定义:Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.(用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象)。1.2 通用类图:原型模式的核心是一个clone方原创 2012-05-16 23:04:42 · 805 阅读 · 0 评论 -
设计模式之08中介者模式(笔记)
1 定义:1.1 定义:Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary thei原创 2012-05-16 23:11:21 · 700 阅读 · 0 评论 -
六大原则之“单一职责原则(SRP)“笔记
1.单一职责原则,(Single Responsibility Principle).定义:There should never be more than one reason for a class to change,应该有且仅有一个原因引起类的变更。职责:业务逻辑,或者对象能够承担的责任,并以某种行为方式来执行。2.理解该原则提出了对对象职责的一种理想期望。对原创 2012-04-03 17:14:29 · 14417 阅读 · 3 评论