Introduction to Dynamic Programming
Dynamic programming is a method for efficiently solving a broad range of search and optimization problems which exhibit the characteristics of overlappling subproblems and optimal substructure. I’ll...
View ArticleDesign Pattern: Factory
from: http://www.jdon.com/designpatterns/designpattern_factory.htm 工厂模式定义:提供创建对象的接口. 为何使用?工厂模式是我们最常用的模式了,著名的Jive论坛 ,就大量使用了工厂模式,工厂模式在Java程序系统可以说是随处可见。...
View ArticleStrategy Pattern
from: http://www.oodesign.com/strategy-pattern.html Motivation There are common situations when classes differ only in their behavior. For this cases is a good idea to isolate the algorithms in...
View Article关于23种设计模式的有趣见解(
创建型模式 1、FACTORY—追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务员说“来四个鸡翅”就行了。麦当劳和肯德基就是生产鸡翅的Factory...
View ArticleDesign Principle
1. Separating what changes from what stays the same - Take the parts that vary and encapsulate them, so that later you can alter or extend the parts that vary without affecting those that...
View ArticleSingleton Pattern
from: http://www.oodesign.com/singleton-pattern.html Motivation Sometimes it’s important to have only one instance for a class. For example, in a system there should be only one window manager (or only...
View ArticleDecorator Pattern
from: http://www.oodesign.com/decorator-pattern.html Motivation Extending an object�s functionality can be done statically (at compile time) by using inheritance however it might be necessary to extend...
View ArticleDAO如何与业务层解耦
在没有使用代理模式的时候,使用者和被使用者耦合。 使用代理模式之后,使用者和代理耦合,代理和被使用者耦合。 为什么要解耦呢?通常是应为变化,需求变化导致最终的程序实现变化,如果耦合度高,出现变化时所需要修改的程序就多,如果进行解耦,那修改的程序就少(被解耦的部分已经不需要修改,因为和变化的地方没有直接的关系了)。 下面举个不太恰当的例子。...
View ArticleJ2EE中几种业务代理模式的实现和比较
什么是业务代理模式(buiness proxy)? 在J2EE系统中,一般划分为表现层和业务逻辑层,为实现表现层和业务逻辑层之间的最大限度解耦,引入业务代理模式,这样,当表现层或业务逻辑层具体实现技术发生时,对彼此的影响很小,当然,如果希望实现完全解耦,我们可以使用消息系统JMS来实现,本文章只讨论同步系统范畴。...
View ArticleAnnotation与工厂模式解耦dao与service
开发中往往service、dao并行完成,但是service层又需要调用dao层的CRUD方法,这意味着dao必须先于service完成。这在开发中会极大降低效率的。 通过注解(Annotatoin)我们可以轻松实现两个层次的解耦 首先写一个注解类 @Retention(RetentionPolicy.RUNTIME) public @interface getClassAnnotation{...
View Article