Design Pattern
文章平均质量分 54
dr2tr
这个作者很懒,什么都没留下…
展开
-
Intercepting Filter模式
Intercepting Filter设计模式,在Web曾处理前进行过滤。一种很有用的过滤是用户是否登陆的安全性检查。即在以下的doFilter函数中添加安全性检查的语句,这样就不需要对每个页面(servlet)进行安全性配置。通常通过实现javax.servlet.Filter接口实现,其主要方法有: Method Summa原创 2006-03-09 08:11:00 · 1648 阅读 · 0 评论 -
Design Patterns -- Abstract Factory
The intent of Abstract Factory is to provide for the creation of a family of related, or dependent, objects. see pic:Additional note is below:( reference from http://www.dofactory.com) : A原创 2006-07-13 11:03:00 · 809 阅读 · 0 评论 -
Adapter模式的理解
Adapter模式的本质正如它的名字一般,是为了提供适配。所谓适配,以中文的解释来说,是两种不同物质间为交流而存在的媒介。在程序里,是为了同时达到利用(adaptee) ,满足(target) 这两个目的而提供的中间体。Adapter模式中的对象主要包括Target(客户需要的接口定义,这个接口不只是Java里的interface,而是普遍意义上的功能接口),Adapter(实际我们需要完成的原创 2006-07-20 15:10:00 · 828 阅读 · 0 评论 -
Design Patterns -- Factory Method
The Factor Method pattern lets a class developer define the interface for creating an object while retaining control of which class to instantiate, see pic:To summarize, the signs that Factory Met原创 2006-07-12 10:12:00 · 823 阅读 · 0 评论 -
Design Patterns -- Prototype
The intent of the prototype pattern is to provide new objects by copying examples. A major difference caused by copying is that a copy typically includes some of the state of the original object.The原创 2006-07-31 10:27:00 · 900 阅读 · 0 评论 -
Design Patterns -- Memento
The intent of the Memento Pattern is to provide storage and restoration of an objects state. In Design Patterns(GoF) , the intent of the Memento Pattern is stated as "Without violating encapsulation原创 2006-08-01 11:43:00 · 1079 阅读 · 0 评论 -
Liskov Substitution Principle
Liskov Substitution Principle, 由Barbara Liskov 和 Jeannette Wing在93年提出,其原文为:“Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a sub原创 2007-03-08 11:15:00 · 1549 阅读 · 0 评论 -
Design Pattern -- Decorator
Decorator 模式, 其功能为;Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. 类图表示为:解释一下这张图,这个模式主要有两点:1原创 2007-03-09 14:36:00 · 1256 阅读 · 0 评论 -
Design Pattern -- Iterator
就Java 开发者而言,Iterator 应该是比较容易理解的模式了。 因为用过Java 集合的人会记得有iterator() 这个函数。应用iterator() 返回Iterator 对象,然后对相应的集合元素进行操作,这就是经典的Iterator 的用法。(当然,Iteartor 还涉及另外一个模式,Factory, 这在之前已经讲过)。在基本的Iterator 模式的定义里是这样讲的:“原创 2007-03-12 13:59:00 · 1130 阅读 · 0 评论 -
Design Patterns -- Visitor
Visitor 模式是这个系列文章(也是笔者在读的这本书)的最后一个模式。按惯例,首先给出定义:Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of t原创 2007-03-13 17:10:00 · 1249 阅读 · 0 评论 -
Design Patterns -- Chain of Responsibility (CoR)
1. The intent of the Chain of Responsibility is to avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. To apply this pattern, chain t原创 2006-07-05 10:06:00 · 1163 阅读 · 1 评论 -
Design Patterns -- Proxy
1。代理的分类: 远程(Remote)代理:为一个位于不同的地址空间的对象提供一个局域代表对象。这个不同的地址空间可以是在本机器中,也可是在另一台机器中。远程代理又叫做大使(Ambassador)。 虚拟(Virtual)代理:根据需要创建一个资源消耗较大的对象,使得此对象只在需要时才会被真正创建。 Copy-on-Write代理:虚拟代理的一种。把复制(克隆转载 2006-07-04 17:07:00 · 806 阅读 · 0 评论 -
Design Patterns -- Builder
The Builder pattern moves the construction logic for an object outside the class to instantiate. It separates the construction of a complex object from its representation. This is especially useful w原创 2006-07-10 10:13:00 · 810 阅读 · 0 评论 -
MVC Tips
1. Its for clearer code and more easily extensiblity.2. Three parts: one represents the business information, one the visual representation and one the control mapping between the view and business原创 2006-05-10 11:43:00 · 699 阅读 · 0 评论 -
Operation Patterns中Template Method, State和Strategy的理解和分析
闲话不多说,先从Template Method开始。对于Template Methods,官方(指GoF书中)的定义的是:"Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certai原创 2006-10-10 22:01:00 · 1320 阅读 · 0 评论 -
Design Patterns --Adapter
1. Class AdapterTarget是原来就有的接口,AdapterA是我们自己实现的类。这个图的关键是AdapterA实现了Target,并且继承了Adaptee。2. Object AdapterTarget 也有可能是抽象类。这个图的关键是,AdapterB实现或者继承了Target,并且Adaptee被以引用或者聚合的方式用在AdapterB中。另外,只有O原创 2006-06-20 16:10:00 · 739 阅读 · 0 评论 -
Design Patterns -- Facade
1. The intent of the FACADE pattern is to provide an interface that makes a subsystem easy to use.2. A facade class may have all static methods.3. The JOptionPane class is one of the few examples原创 2006-06-21 10:57:00 · 791 阅读 · 0 评论 -
Design Patterns -- Bridge
1. The intent of the BRIDGE pattern is to decouple an abstraction (a class that relies on a set of abstarct operations, GoF Design Patterns) from the implementation of its abstract operation, so tha原创 2006-06-22 10:24:00 · 884 阅读 · 0 评论 -
Design Patterns -- Singleton
1. The intent of the Singleton is to ensure that a class has only one instance and to provide a global point of access to it.2. A singleton is usually lazy-initialized. [lazy-initialized is like:if(原创 2006-06-26 10:32:00 · 798 阅读 · 0 评论 -
Design Patterns -- Obeserver
1. The intent of the Observer pattern is to define a one-to-many dependency such that when one object changes state, all its dependents are notified and updated automatically. see pic:The Subject原创 2006-06-27 10:16:00 · 803 阅读 · 0 评论 -
Design Patterns -- Mediator
1. The Medaitor pattern centralizes responsibility for a particular set of objects. (Singleton pattern is for the clients.) The Mediator pattern defines an object that encapsulates how a set of object原创 2006-06-28 09:51:00 · 802 阅读 · 0 评论 -
Design Patterns -- Flyweight
The intent of Flyweight is to use sharing to support large numbers of fine-grained objects efficiently. see pic: A preliminary step in applying the Flyweight pattern is to extract the immutable原创 2006-07-06 10:30:00 · 918 阅读 · 0 评论 -
Singleton和Double Check
首先看一段比较经典的代码:public static Singleton getInstance(){ if (instance == null) //0 { synchronized(Singleton.class) { if (instance == null) instance = new Singleton();原创 2007-08-03 17:00:00 · 2069 阅读 · 0 评论