- 博客(25)
- 收藏
- 关注
原创 web.xml 中的listener、 filter、servlet 加载顺序
[b]一、 [/b]1、启动一个WEB项目的时候,WEB容器会去读取它的配置文件web.xml,读取和两个结点。 2、紧急着,容创建一个ServletContext(servlet上下文),这个web项目的所有部分都将共享这个上下文。 3、容器将转换为键值对,并交给servletContext。 4、容器创建中的类实例,创建监听器。 [b]二、[/b] load-on-...
2011-03-23 21:00:24
152
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
serialized objects
This started again... a thread from *****:What do you consider a best practice for serialVersionUID?T______________________________________________From: ******* Sent: Thursday, Nov...
2010-03-31 14:23:20
198
UML中关联(association)和依赖(dependency)的区别
这个问题不仅我们这些小喽罗会迷惑,很多大拿们也没有统一的认识,争论常有。在UML2.0 规范中,有些以前归为一方的现在被归为另一方。下面是从网上搜集的一些看法:---------1.--------- Dependency Relationship Draw a dependency relationship between two classes, o...
2010-03-30 08:56:53
739
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
119
Static Initializers and Lazy Instantiation
Why use Lazy Instantiation when static initialization is more efficient? Well, there are pros and cons to both, and there is no firm answer.The Singleton article gave one solution for implementing...
2010-03-27 11:14:14
165
vim图
随便看看:[img]http://dl.iteye.com/upload/attachment/214810/112ca5b3-84c4-3eec-b811-007019e8083a.jpg[/img]
2010-03-09 14:27:59
118
原创 当一个线程进入一个对象的一个synchronized方法后,其它线程是否可进入此对象的其它方法?...
当一个线程进入一个对象的一个synchronized方法后,其它线程是否可进入此对象的其它方法?日前在网上见到一道Java笔试试题,如题所述。给出的答案如下:答:不能,一个对象的一个synchronized方法只能由一个线程访问。 本人认为有些所答非所问。故写了两个demo进行测试。发现答案要分三种情况讨论。 [list][*][b]情况一:[/b][/li...
2010-01-24 10:23:04
159
原创 Set是如何实现"没有重复元素" - hashCode compareTo equals
Set和数学中的集合是同一个概念,就是没有重复元素的集合。这篇文章主要论述了Set是如何实现"没有重复元素"(no duplicate elements)的,以及阐述了什么是“重复”(duplicate),是相同的地址空间?是equals的返回值为true?是compareTo的返回值为0 ?还是有相同的hashCode?本文还给出了在什么情况下使用什么样的Set的建议。注:本文不...
2010-01-24 10:01:23
156
原创 UML中几种类间关系:继承、实现、依赖、关联、聚合、组合
[list][*]继承,泛化(Generalization)[/list]指的是一个类(称为子类、子接口)继承另外的一个类(称为父类、父接口)的功能,并可以增加它自己的新功能的能力,继承是类与类或者接口与接口之间最常见的关系;在Java中此类关系通过关键字extends明确标识,在设计时一般没有争议性[img]http://dl.iteye.com/upload/attachm...
2009-12-06 23:13:56
184
原创 Build模式的理解
Builder模式是为了将构建复杂对象的组装过程和它的创建部件与产品对象分离.注意: [b]是解耦组装过程和创建具体部件[/b].[b]过程实现使用Director,它仅关心组装部件的过程,不关心每个具体部件的创建。而Builder则是定义出创建部件的接口,然而具体的创建,则是有ConcreteBuilder来实现。[/b]由于在Director使用是Builder接口所以,这...
2009-11-26 23:23:14
298
原创 设计模式简图
[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
158
原创 正确使用 Volatile 变量
Java™ 语言包含两种内在的同步机制:同步块(或方法)和 volatile 变量。这两种机制的提出都是为了实现代码线程的安全性。其中 Volatile 变量的同步性较差(但有时它更简单并且开销更低),而且其使用也更容易出错。在这期的 Java 理论与实践 中,Brian Goetz 将介绍几种正确使用 volatile 变量的模式,并针对其适用性限制提出一些建议。 Java 语言...
2009-11-25 23:24:32
119
原创 面向对象设计原则
正如牛顿三大定律在经典力学中的位置一样,“开-闭”原则(Open-Closed Principle)是面向对象的可复用设计(Object Oriented Design或OOD)的基石。其他设计原则(里氏代换原则、依赖倒转原则、合成/聚合复用原则、迪米特法则、接口隔离原则)是实现“开-闭”原则的手段和工具。 一、“开-闭”原则(Open-Closed Principle,OCP)...
2009-11-07 09:43:10
101
原创 Java class loader
[list][*]1. Explain Java class loader?[/list]Class loader are hierarchical and use a delegation model when loading a class. Here is the “Typical Default Class Loader Hierarchy”.[img]ht...
2009-10-29 23:33:26
143
原创 JVM知识点题目
JVM是Java程序的运行环境,因此对于JVM的掌握有助于理解Java程序的执行以及编写,尤其是运行时碰到的一些诡异问题,那么怎么样能考察自己对于JVM关键知识点的掌握情况,帮助学习JVM机制呢,在这篇blog中来探讨下。对于Java程序而言,JVM的关键机制有:字节码的加载、方法的执行、对象内存的分配和回收、线程和锁机制,这几个机制涉及到的jvm的知识点远没有写这几个字这么简单,里面的复...
2009-10-28 20:58:59
142
原创 Marker Interface
Marker interface having no methods right.. then what is the use of marker interface? for what purpose we use marker interface?One of the "clean" features of the Java programming language is that i...
2009-09-29 16:11:23
182
原创 Flyweight Pattern 享元模式
GOF:运用共享技术有效地支持大量细粒度的对象。 解释一下概念:也就是说在一个系统中如果有多个相同的对象,那么只共享一份就可以了,不必每个都去实例化一个对象。比如说(这里引用GOF书中的例子)一个文本系统,每个字母定一个对象,那么大小写字母一共就是52个,那么就要定义52个对象。如果有一个1M的文本,那么字母是何其的多,如果每个字母都定义一个对象那么内存早就爆了。那么如果要是每个字母都共...
2009-09-29 16:07:32
102
原创 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
132
原创 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
137
原创 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
93
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
95
原创 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
原创 Java Immutable Class
Java Immutable Class[ From ]immutable object提供了极具价值的服务。由于他们保证自己的状态从构建之后就一定不再改变。因此他们天生具备多线程安全性。所以我们可以不必对它进行同步控制,这样可能能够提高些性能。但是实现immutable object时你必须实现clone(克隆)功能,而其代价可能不小。要将一个类变成immutable是要通过...
2009-09-27 14:09:54
91
原创 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
150
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人