
Design Pattern
文章平均质量分 64
iteye_8951
这个作者很懒,什么都没留下…
展开
-
面向对象设计原则
正如牛顿三大定律在经典力学中的位置一样,“开-闭”原则(Open-Closed Principle)是面向对象的可复用设计(Object Oriented Design或OOD)的基石。其他设计原则(里氏代换原则、依赖倒转原则、合成/聚合复用原则、迪米特法则、接口隔离原则)是实现“开-闭”原则的手段和工具。 一、“开-闭”原则(Open-Closed Principle,OCP)...原创 2009-11-07 09:43:10 · 101 阅读 · 0 评论 -
Using the Prototype pattern to clone objects
Prototype pattern is one of the creational patterns that concentrate on duplicating objects if needed. Assuming that we are in process of creating a template. Most of the times, we copy an existing te...原创 2009-09-27 15:48:23 · 133 阅读 · 0 评论 -
Is a Java Immutable Class Always final?
In response to my recent blog posting Immutable Java Objects, Matt brought up a good point of discussion related to making Java classes truly immutable by declaring them as final so that they cannot b...原创 2009-09-27 15:10:16 · 138 阅读 · 0 评论 -
Defensive copying
A mutable object is simply an object which can change its state after construction. For example, StringBuilder and Date are mutable objects, while String and Integer are immutable objects.A class ...原创 2009-09-27 14:46:58 · 94 阅读 · 0 评论 -
Copy constructors
Copy constructors :[list][*] provide an attractive alternative to the rather pathological clone method[*] are easily implemented[*] simply extract the argument's data, and forward t...2009-09-27 14:29:53 · 96 阅读 · 0 评论 -
Immutable objects
Immutable objects are simply objects whose state (the object's data) cannot change after construction. Examples of immutable objects from the JDK include String and Integer.Immutable objects great...原创 2009-09-27 14:13:17 · 284 阅读 · 0 评论 -
Java Immutable Class
Java Immutable Class[ From ]immutable object提供了极具价值的服务。由于他们保证自己的状态从构建之后就一定不再改变。因此他们天生具备多线程安全性。所以我们可以不必对它进行同步控制,这样可能能够提高些性能。但是实现immutable object时你必须实现clone(克隆)功能,而其代价可能不小。要将一个类变成immutable是要通过...原创 2009-09-27 14:09:54 · 92 阅读 · 0 评论 -
Value Object vs. Data Transfer Object (VO vs. DTO)
The pattern which is known today as Data Transfer Object was mistakenly (see this definition) called Value Object in the first version of the Core J2EE Patterns. The name was corrected in the second e...原创 2009-09-18 10:31:43 · 151 阅读 · 0 评论 -
Facade vs Proxy
[b]Question:[/b]i feel there is not much difference between a facade and proxy pattern, and they can be exchanged for each other in some cases ., can someone provide light on the diffence in these p...2010-04-02 08:36:33 · 155 阅读 · 0 评论 -
UML中关联(association)和依赖(dependency)的区别
这个问题不仅我们这些小喽罗会迷惑,很多大拿们也没有统一的认识,争论常有。在UML2.0 规范中,有些以前归为一方的现在被归为另一方。下面是从网上搜集的一些看法:---------1.--------- Dependency Relationship Draw a dependency relationship between two classes, o...2010-03-30 08:56:53 · 743 阅读 · 0 评论 -
Aggregation v.s. Composition
[b]Aggregation[/b]Aggregation is a kind of association that specifies a whole/part relationship between the aggregate (whole) and component part. This relationship between the aggregate and compon...2010-03-30 08:13:12 · 120 阅读 · 0 评论 -
UML中几种类间关系:继承、实现、依赖、关联、聚合、组合
[list][*]继承,泛化(Generalization)[/list]指的是一个类(称为子类、子接口)继承另外的一个类(称为父类、父接口)的功能,并可以增加它自己的新功能的能力,继承是类与类或者接口与接口之间最常见的关系;在Java中此类关系通过关键字extends明确标识,在设计时一般没有争议性[img]http://dl.iteye.com/upload/attachm...原创 2009-12-06 23:13:56 · 185 阅读 · 0 评论 -
Build模式的理解
Builder模式是为了将构建复杂对象的组装过程和它的创建部件与产品对象分离.注意: [b]是解耦组装过程和创建具体部件[/b].[b]过程实现使用Director,它仅关心组装部件的过程,不关心每个具体部件的创建。而Builder则是定义出创建部件的接口,然而具体的创建,则是有ConcreteBuilder来实现。[/b]由于在Director使用是Builder接口所以,这...原创 2009-11-26 23:23:14 · 300 阅读 · 0 评论 -
设计模式简图
[img]http://dl.iteye.com/upload/attachment/172975/a4dd60ba-89b4-3a1d-8e6c-3a59f8f8354b.jpg[/img][img]http://dl.iteye.com/upload/attachment/172979/79a37d86-fcf9-34d0-85db-1c363083a464.jpg[/img]...原创 2009-11-26 22:00:34 · 159 阅读 · 0 评论 -
Flyweight Pattern 享元模式
GOF:运用共享技术有效地支持大量细粒度的对象。 解释一下概念:也就是说在一个系统中如果有多个相同的对象,那么只共享一份就可以了,不必每个都去实例化一个对象。比如说(这里引用GOF书中的例子)一个文本系统,每个字母定一个对象,那么大小写字母一共就是52个,那么就要定义52个对象。如果有一个1M的文本,那么字母是何其的多,如果每个字母都定义一个对象那么内存早就爆了。那么如果要是每个字母都共...原创 2009-09-29 16:07:32 · 104 阅读 · 0 评论