![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
liuxinglanyue
这个作者很懒,什么都没留下…
展开
-
JDK里的设计模式
下面是JDK中有关23个经典设计模式的示例,在stakeoverflow也有相应的讨论:http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns Structural(结构模式) Adapter:把一个接口或是类变成另外一种。 java.util.Arrays#asList() jav...原创 2010-12-16 19:35:36 · 68 阅读 · 0 评论 -
设计模式英文手稿(转)
暑期实习的时候做了一次presentation on design pattern,以下是做的draft(由于公司算半个外企,用的英文;) Design patterns are recurring solutions to software design problems you find again and again in real-world application development...原创 2010-11-15 15:50:27 · 178 阅读 · 0 评论 -
推拉模式
先来比较两张 UML 图: 推模式 拉模式 两者的区别我再罗嗦一下,推模式是当通知消息来之时,把所有相关信息都通过参数的形式“推给”观察者。而拉模式是当通知消息来之时,通知的函数不带任何相关的信息,而是要观察者主动去“拉”信息。 推模式的优点是当消息来临时,观察者很直接地都到信息,然后进行相关地处理,与被观察者没有一点联系,两者几乎...原创 2010-11-15 15:35:14 · 959 阅读 · 0 评论 -
观察者模式
作用: 在某一个对象的状态发生变化的时候,某些其它的对象做出相应的改变。 正文: 观察者模式是一对多的模式,是那种你一旦理解了,就会觉得到处都可以用的模式之一,所以你一定要抵挡的住诱惑,过度使用观察者模式往往会导致系统难以理解和跟踪。 观察者模式分为两种模型,为拉模型和推模型。 让我们来看个例子。 冬天的早上,起床是件痛苦的事...原创 2010-11-15 15:34:16 · 81 阅读 · 0 评论 -
追MM与Java的23种设计模式(转)
我在Java论坛看到这篇文章,作者以轻松的语言比喻了java的32种模式,有很好的启发作用,但可惜没有给出具体的意思,我就在后边加上了。这些都是最简单的介绍,要学习的话建议你看一下阎宏博士的《Java与模式》一书。 创建型模式 1、FACTORY—追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务员说“来四个鸡翅...原创 2010-11-14 22:21:15 · 70 阅读 · 0 评论 -
关于设计模式的非常好的站点
http://www.uml.org.cn/sjms/sjms.asp#30原创 2010-11-14 22:10:23 · 74 阅读 · 0 评论 -
Java设计模式之组合模式
COMPOSITE (Object Structural) Purpose Facilitates the creation of object hierarchies where each object can be treated independently or as a set of nested objects through the same interface. Use When 1...原创 2010-11-14 20:54:04 · 66 阅读 · 0 评论 -
Java设计模式之观察者模式
OBSERVER (Object Behavioral) Purpose Lets one or more objects be notified of state changes in other objects within the system. Use When 1 State changes in one or more objects should trigger behavior ...原创 2010-11-14 20:53:32 · 69 阅读 · 0 评论 -
Java设计模式之代理模式
PROXY (Object Structural) Purpose Allows for object level access control by acting as a pass through entity or a placeholder object. Use When 1 The object being represented is external to the system. ...原创 2010-11-14 20:53:09 · 75 阅读 · 0 评论 -
Java设计模式之模板方法模式
TEMPLATE METHOD (Class Behavioral) Purpose Identifies the framework of an algorithm, allowing implementing classes to define the actual behavior. Use When 1 A single abstract implementation of an algo...原创 2010-11-14 20:52:19 · 59 阅读 · 0 评论 -
Java设计模式之抽象工厂模式
ABSTRACT FACTORY (Object Creational) Purpose Provide an interface that delegates creation calls to one or more concrete classes in order to deliver specific objects. Use When n The creation of objects...原创 2010-11-14 20:51:47 · 63 阅读 · 0 评论 -
Java设计模式之状态模式
STATE (Object Behavioral) Purpose Ties object circumstances to its behavior, allowing the object to behave in different ways based upon its internal state. Use When 1 The behavior of an object sho...原创 2010-11-14 20:51:18 · 65 阅读 · 0 评论 -
Java设计模式之策略模式
STRATEGY (Object Behavioral) Purpose Defines a set of encapsulated algorithms that can be swapped to carry out a specific behavior. Use When 1 The only difference between many related classes is ...原创 2010-11-14 20:50:52 · 71 阅读 · 0 评论 -
Java设计模式之装饰者模式
DECORATOR (Object Structural) Purpose Allows for the dynamic wrapping of objects in order to modify their existing responsibilities and behaviors. Use When 1 Object responsibilities and behavi...原创 2010-11-14 20:49:24 · 90 阅读 · 0 评论 -
Java设计模式之单例模式
SINGLETON (Object Creational) Purpose Ensures that only one instance of a class is allowed within a system. Use When 1 Exactly one instance of a class is required. 2 Controlled access to ...原创 2010-11-14 20:48:28 · 63 阅读 · 0 评论 -
7种坏味道,11种原则,23种模式
(一)7种设计坏味道 1.僵化性: 很难对系统进行改动,因为每个改动都会迫使许多对系统其他部分的其它改动。 2.脆弱性: 对系统的改动会导致系统中和改动的地方在概念上无关的许多地方出现问题。 3.牢固性: 很难解开系统的纠结,使之成为一些可在其他系统中重用的组件。 4.粘滞性: 做正确的事情比做错误的事情要困难。 5.复杂性(不必要的): 设计中包含有不具任何直接好处的基...原创 2010-11-14 20:46:46 · 132 阅读 · 0 评论 -
JDK里的设计模式(二)
Flyweight (recognizeable by creational methods returning a cached instance, a bit the "multiton" idea) java.lang.Integer#valueOf(int) (also on Boolean, Byte, Character, Short, Long, Floatand Do...2010-12-16 19:45:50 · 81 阅读 · 0 评论 -
JDK里的设计模式
Creational patterns Abstract factory (recognizeable by creational methods returning an abstract/interface type) java.util.Calendar#getInstance() java.util.Arrays#asList() java.util.Resourc...2010-12-16 19:39:21 · 72 阅读 · 0 评论 -
JDK里的设计模式
下面是JDK中有关23个经典设计模式的示例,在stakeoverflow也有相应的讨论:http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns Structural(结构模式) Adapter:把一个接口或是类变成另外一种。 java.util.Arrays#asList() jav...原创 2010-11-28 10:42:43 · 58 阅读 · 0 评论