
Java
EricYeung
这个作者很懒,什么都没留下…
展开
-
用linked list 来理解Decorator 模式
/* * decorator in linked list s point of view ?????? */class TestClass { String desc; TestClass tc; public TestClass(TestClass tc, String desc) { this.tc = tc;原创 2006-02-13 12:04:00 · 1044 阅读 · 0 评论 -
(Item 11) Comparable
(Item 11) ComparableWhy: by implementing comparable, your class can interoperate with many generic algorithms.Contract: compare the object with another, return a negative integer, zero, or positiv原创 2007-05-13 21:29:00 · 11006 阅读 · 0 评论 -
(Item 10) Override clone() judiciously
(Item 10) Override clone() judiciouslyGeneral Contractx.clone() != xx.clone().getClass() == x.getClass()x.clone().equal(x) == true In practice, a class that implements Cloneable is expe原创 2007-05-13 21:16:00 · 886 阅读 · 0 评论 -
(Item 2) singleton
(Item 2) singleton//use final fieldpublic class Elvis { public static final Elvis INSTANCE = new Elvis(); //public field private Elvis() { .. }} //use static factory, give原创 2007-05-06 23:56:00 · 825 阅读 · 0 评论 -
(Item 1) use static factory to substitute constructors
(Item 1) use static factory to substitute constructorsmore meaningful name than constructor namedon’t require to create new instance each time they’re invokedreturn object of any subtype (map st原创 2007-05-06 23:54:00 · 839 阅读 · 0 评论 -
(Item 7) Override equlas()
(Item 7) Override equlas()1) Use == to check “this”2) Use instanceof to check type3) Cast argument to correct type4) Check equality of each significant fields5) Ask yourself原创 2007-05-11 00:07:00 · 983 阅读 · 0 评论 -
(Item 6) Avoid finalizer
(Item 6) Avoid finalizer1) Java Language Specification provide no guarantee that finalizer will get executed.2) Nothing time-critical should ever be done in finalizer (e.g. close file)3) Don’t s原创 2007-05-07 00:09:00 · 866 阅读 · 0 评论 -
TIJ Note - Object creation process
[the content of this article is summaried from Thinking In Java]The process of creating an object. Consider a class called Dog: The first time an object of type Dog is created (the const原创 2007-05-06 12:05:00 · 916 阅读 · 0 评论 -
(Item 8) Override hashCode when you override equals()
(Item 8) Override hashCode when you override equals()Incentivepublic final class PhoneNumber { private final short areaCode; private final short exchange; private fin原创 2007-05-11 00:23:00 · 1128 阅读 · 0 评论 -
(Item 5) Eliminate obsolete object references
(Item 5) Eliminate obsolete object referencespublic class Stack { private Object[] elements; private int size = 0; public Stack(int initialCapacity) { this.elements =原创 2007-05-07 00:05:00 · 903 阅读 · 0 评论 -
(Item 4) Avoid creating duplicate objects, reuse immutable objects
(Item 4) Avoid creating duplicate objects, reuse immutable objectsString s = new String(“Created each time when executed!!”); // DON’T DO THISA improved versionString s = “A reusable string”;原创 2007-05-06 23:58:00 · 887 阅读 · 0 评论 -
TIJ Note - Garbage collection
[the content of this article is summaried from Thinking In Java]1) Your object might not get garbage collectedAll is controlled by JVM2) Garbage collection is not destructions3)原创 2007-05-06 12:00:00 · 843 阅读 · 0 评论 -
图解eclipse+myelcipse开发EJB[ZZ] + My Deployment
在开发ejb之前,我们先得配置好服务器,我使用的是Weblogic9.0中文版,关于Weblogic9.0配置请看我的另一片文章。配置Weblogic9.0 首先需要配置好eclipse。我这里主要说明weblogic的配置。 注意JDK选择JDK5.0的版本。 顺便将weblogic8的配置也贴上来,供大家比较参考 注意weblo转载 2007-06-20 14:49:00 · 2624 阅读 · 0 评论 -
Simplest HTTP-JSP-Servlet-Struts-JDBC-Hibernate demo
Java Webx86 Assembly = ServletC = JSPC++ = JSF================================Online Shopping CartHTTP Cookies vs. HTTP QueryString/Web beacon================================HTTP Query StringTec原创 2007-05-24 11:14:00 · 1329 阅读 · 0 评论