
DesignPattern
macrotea
macrotea
展开
-
访问者模式
import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Random; public class Mainer { public static void main(String[] args) { List flowers = new Arra...原创 2011-05-20 11:34:45 · 87 阅读 · 0 评论 -
《有些模式》- 服务提供者
/** * 服务接口 * @author Macrotea * */ public interface Service { public abstract void doSomeService(); } /** * 服务提供者接口 * @author Macrotea * */ public interface Provider { ...原创 2010-10-25 21:13:42 · 83 阅读 · 0 评论 -
《有些模式》- 类型推导
public class Temp { public static void main(String[] args) { //第一种方式 HashMap<String, Double> hmap = new HashMap<String, Double>(); //类型推导方式 HashMap<String, Double> hmap...原创 2010-10-25 21:21:36 · 80 阅读 · 0 评论 -
《有些模式》- Builder
或许你已经看惯了javabean和层叠构造. /** * Builder模式 * @author Macrotea * */ public class ManFacts { private String name; private int age; private double height; private double weight; ...原创 2010-10-26 09:51:55 · 109 阅读 · 0 评论 -
《有些模式》- 责任链(简单模拟1)
package com.macrotea.responzchain.interfazz; public interface Filter { public String doFilter(String text); } package com.macrotea.responzchain.impl; import com.macrotea.responzchain.inter...原创 2010-10-28 17:21:28 · 79 阅读 · 0 评论 -
《有些模式》- 责任链(简单模拟2)
package com.macrotea.responzchain.entity; public class Request { private String content; public String getContent() { return content; } public void setContent(String content) { th...原创 2010-10-28 21:22:32 · 87 阅读 · 0 评论 -
《有些模式》- 抽象工厂
package com.macrotea.pattern.factory.abstr; import com.macrotea.pattern.factory.base.Food; import com.macrotea.pattern.factory.base.Vehicle; import com.macrotea.pattern.factory.base.Weapon; ...原创 2010-11-02 11:12:41 · 69 阅读 · 0 评论