DesignPattern
文章平均质量分 90
davyjones2010
生活在这个世界而不知其义,如同徜徉于一座伟大的图书馆而不碰书籍。
展开
-
DesignPattern : Chain-Of-Responsibility
1. Application Scenario: 1) We want to build an BBS and enable user to post their comments. How can we filter the sensitive messages that user posted? 2) In chatting room, our mes...原创 2013-05-25 10:39:37 · 113 阅读 · 0 评论 -
Design Pattern: Decorator Pattern
Decorator Pattern 1) Motivation: Extending an object's functionality can be done statically (at compile time) by using inherientence. However it might be necessary to extend an object's fun...原创 2014-07-06 23:03:21 · 222 阅读 · 0 评论 -
DesignPattern: Composite Pattern
Composite Design Pattern1) Motivation: There are many times when a program need to manipulate a tree data structure and it is necessary to treat both Branches as well as Leaf Nodes unifor...原创 2014-07-06 17:23:36 · 185 阅读 · 0 评论 -
UML: Dependency, Association, Aggregation and Composition
1. Dependency: A dependency is a weak relationship between two classes. In this example, there is dependency between Point and LineSegment, because LineSegment's draw() operation u...原创 2014-07-06 13:21:20 · 358 阅读 · 1 评论 -
DesignPattern : Observer
1. Introduction 1. We can infer Observer Design Pattern from JDK GUI part. 2. The AWT and Swing GUI components are using Observer Design Pattern which we will discuss later. 2. A simpl...原创 2013-06-06 00:25:12 · 126 阅读 · 0 评论 -
DesignPattern : Strategy
1. Introduction Look at the example below: We want to sort an array of integer. 1) Test casepackage edu.xmu.designPattern.DesignPattern_Strategy;import java.util.ArrayList;imp...原创 2013-06-04 01:01:59 · 155 阅读 · 0 评论 -
DesignPattern : Factory
1. Why should we use Factory Method? 1) We want to control the way we create new instance of a certain class. We cannot merely use the new XXX() to create an instance. 2) We want to keep ou...原创 2013-06-03 16:43:13 · 167 阅读 · 0 评论 -
DesignPattern : Iterator
1. A simple mockup for ArrayListpackage edu.xmu.designPattern.DesignPattern_Iterator;public class ArrayList{ private Object[] objects = new Object[10]; private int index = 0; public ...原创 2013-05-26 22:04:19 · 115 阅读 · 0 评论 -
DesignPattern : Singleton
1. Eager Initialization Approachpackage edu.xmu.designPattern.DesingPattern_Singleton;public class Singleton{ private static Singleton singleton = new Singleton(); private Singleton()...原创 2013-05-25 21:37:15 · 182 阅读 · 0 评论 -
Design Pattern: Builder Pattern
Builder Pattern: The builder pattern is a design pattern that allows for the step-by-step creation of complex objects using the correct sequence of actions. The construction is controlled...原创 2014-07-21 15:39:55 · 194 阅读 · 0 评论