在Java 核心类库中关于GOF设计模式的例子

原文地址:http://blog.csdn.net/jiangkai528/article/details/45195915

在Java 核心类库中关于GOF设计模式的例子

问题:   我正在学习GOF的java 设计模式,我想找一些它们中鲜活的例子,在java 核心类库中有哪些好的例子呢?

回答:你可以在维基百科上获得许多设计模式概述。同时也会提到哪些是由GOF提出的。在这里我总结一下,我尽可能多的从java SE 和java EE 的 API 中选取一些设计模式的实现

1.抽象工厂模式 (abstract factory)

2.生成器模式(builder)

3. 工厂方法模式(factory method)

4. 原型模式(prototype)

5.单例模式 (singleton)

6.适配器模式(adapter)

7. 桥接模式(bridge)

None comes to mind yet. A fictive example would be new LinkedHashMap(LinkedHashSet<K>, List<V>) which returns an unmodifiable linked map which doesn't clone the items, butuses them. Thejava.util.Collections#newSetFromMap() and singletonXXX() methods however comes close.

8.组合模式(composite)

9.装饰模式(decorator)

10.外观模式(facade)

11.享元模式(flyweight)

java.lang.Integer#valueOf(int) (同时还有Boolean,Byte,Character,Short and Long)


12.代理模式(proxy)

13. 职责链模式(chain of responsibility)

14. 命令模式(command)

15. 解析器模式(interpreter)


16. 迭代器模式 (iterator)

17. 中介者模式 (mediator)


18.备忘录模式(memento)

19. 观察者模式(observer)

20.状态模式(state)

javax.faces.lifecycle.LifeCycle#execute()

(controlled by FacesServlet, the behaviour is dependent on current phase (state) of JSF lifecycle)


21.策略模式(strategy)


22. 模板方法模式(template method)

23. 访问者模式(visitor)



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值