代码改变世界

Effective Java 11 Override clone judiciously

2014-03-06 22:17 by 小郝(Kaibo Hao), 510 阅读, 0 推荐, 收藏, 编辑
摘要:Principles If you override the clone method in a nonfinal class, you should return an object obtained by invoking super.clone In practice, a class that implements Cloneable is expected to provide a properly functioning public clone method. Never make the client do anything the library can do for the client. The clone architecture is incompatible with normal use of final fields referring to mutable objects 阅读全文

Effective Java 10 Always override toString() method

2014-03-05 18:24 by 小郝(Kaibo Hao), 378 阅读, 0 推荐, 收藏, 编辑
摘要:Advantage Provide meaningful of an object info to client. Disadvantage Constrain the ability of changing the toString() implementation since this will affect the client who use this formatted string as persistence. 阅读全文

Effective Java 09 Always override hashCode when you override equals

2014-03-04 19:31 by 小郝(Kaibo Hao), 415 阅读, 0 推荐, 收藏, 编辑
摘要:Failure to do so will result in a violation of the general contract for Object.hashCode, which will prevent your class from functioning properly in conjunction with all hash-based collections, including HashMap, HashSet, and Hashtable. 阅读全文

Effective Java 08 Obey the general contract when overriding equals

2014-03-02 12:34 by 小郝(Kaibo Hao), 508 阅读, 0 推荐, 收藏, 编辑
摘要:When it's the case that each instance of the class is equal to only itself. 1. Each instance of the class is inherently unique. 2. You don't care whether the class provides a "logical equality" test. 3. If a superclass has already overridden equals, and the superclass behavior is appropriate for this class. 4. The class is private or package-private, and you are certain that its equals method will never be invoked. 阅读全文

Effective Java 07 Avoid finallizers

2014-03-01 21:56 by 小郝(Kaibo Hao), 421 阅读, 0 推荐, 收藏, 编辑
摘要:In summary, don't use finalizers except as a safety net or to terminate noncritical native resources. In those rare instances where you do use a finalizer, remember to invoke super.finalize. If you use a finalizer as a safety net, remember to log the invalid usage from the finalizer. Lastly, if you need toassociate a finalizer with a public, nonfinal class, consider using a finalizer guardian, so finalization can take place even if a subclass finalizer fails to invoke super.finalize. 阅读全文

Effective Java 06 Eliminate obsolete object references

2014-02-28 22:58 by 小郝(Kaibo Hao), 497 阅读, 0 推荐, 收藏, 编辑
摘要:Nulling out object references should be the exception rather than the norm. Another common source of memory leaks is caches. A third common source of memory leaks is listeners and other callbacks. 阅读全文

Effective Java 05 Avoid creating unnecessary objects

2014-02-27 19:31 by 小郝(Kaibo Hao), 366 阅读, 0 推荐, 收藏, 编辑
摘要:When using Adapter pattern don't created an new object of the backing object since there is no need for the specific state of the Adapter object.Prefer primitives to boxed primitives, and watch out for unintentional autoboxing. 阅读全文

Effective Java 04 Enforce noninstantiability with a private constructor

2014-02-26 22:33 by 小郝(Kaibo Hao), 486 阅读, 0 推荐, 收藏, 编辑
摘要:A class can be made noninstantiable by including a private constructor. 阅读全文

Effective Java 03 Enforce the singleton property with a private constructor or an enum type

2014-02-25 21:57 by 小郝(Kaibo Hao), 392 阅读, 0 推荐, 收藏, 编辑
摘要:When implement the singleton pattern please decorate the INSTANCE field with "static final" and decorate the constructor with "private". 阅读全文

Effective Java 02 Consider a builder when faced with many constructor parameters

2014-02-24 10:06 by 小郝(Kaibo Hao), 342 阅读, 0 推荐, 收藏, 编辑
摘要:The Builder pattern is a good choice when designing classes whose constructors or static factories would have more than a handful(>4) of parameters. 阅读全文

Effective Java 01 Consider static factory methods instead of constructors

2014-02-22 20:22 by 小郝(Kaibo Hao), 546 阅读, 0 推荐, 收藏, 编辑
摘要:Unlike constructors, they have names. They are not required to create a new object each time they're invoked(Flyweight pattern). It can return an object of any subtype of their return type.(This gives you great flexibility in choosing the class of the returned object. ) 阅读全文

Save one hour per day for the innovation

2013-04-11 13:28 by 小郝(Kaibo Hao), 217 阅读, 0 推荐, 收藏, 编辑
摘要:Here is the my idea proposed on the Idea-fest activity of my company. I this can help you in some way. If you have any idea on saving time and resources in daily life please leave it in the comments. 阅读全文

CLR via C# - 1. Type fundamentals

2012-12-09 21:19 by 小郝(Kaibo Hao), 180 阅读, 0 推荐, 收藏, 编辑
摘要:The address structure of the type object and typeNote:Every object on the heap requires some additional members—called the type object pointer and the sync block index—used by the CLR to manage the object .System.Object’s GetType method simply returns the address stored in the specified object’s typ 阅读全文

Be careful with the "cache-control"

2012-11-16 17:56 by 小郝(Kaibo Hao), 242 阅读, 0 推荐, 收藏, 编辑
摘要:It has been a long time for me to develop the web application. Today I encountered the cache issue of the Internet explore. By default, the option of the "Check for newer versions of stored pages" of "Temporary Internet Files" is set to "Automatically" which will cause 阅读全文

How to deploy the ASP.NET MVC 3 website into the IIS7 on Windows server 2008

2012-02-26 23:33 by 小郝(Kaibo Hao), 1274 阅读, 0 推荐, 收藏, 编辑
摘要:Recently, my teammates and I are working closely with our new product. I took a task to build a website which forms as an interface to access the status of the product or do some statistic work with the data which input or output thru the product. This website is build with ASP.NET MVC 3 and C#. Eve 阅读全文

NHibernate Notes3_How to set a default value of column

2011-09-25 22:50 by 小郝(Kaibo Hao), 1940 阅读, 1 推荐, 收藏, 编辑
摘要:To set a default value of column with "datetime" type we need to take the advantage of setting the default value of the column within the native DB. In NHibernate we should the set the attritute "generated" to be "alway" or "insert" which will tell NHibernate to fullfill the value of the column with the value assigned from the native DB. Actually there are three value options for the "generated" attribute. 阅读全文

Effective C# 学习笔记导航

2011-09-18 23:04 by 小郝(Kaibo Hao), 3033 阅读, 7 推荐, 收藏, 编辑
摘要:最近一段时间,利用空闲时间读了《Effective C# - 50 Specific Ways to Improve Your C#》的第二版,收获不少,尤其是对于.Net 4.0 新特性(PLINQ、Dynamic programming等)的介绍让人眼前一亮,激发了许多新的思路。书是英文的,自己写了些中文的笔记,主要是用于帮助自己记住这些知识点,几乎每个笔记都有知识点的总结和相应的代码。也希望能对大家有所帮助 :)。导航分部分列出各个笔记,以便大家查找方便:) 阅读全文

Effective C# 学习笔记(五十)构建小型内聚程序集

2011-09-12 23:17 by 小郝(Kaibo Hao), 401 阅读, 0 推荐, 收藏, 编辑
摘要:构建程序集的考虑要点 1. 将处理一个功能集的公有类型及其基类和接口放到一个程序中 2. 将各个公有类型共用的Utility类作为internal放到该程序集中 3.将各个程序集公用的Utility单独构建程序集(如:logging、Exception Handling) 阅读全文

NHibernate Notes1_Creating Class Hierarchy mappings

2011-09-04 22:50 by 小郝(Kaibo Hao), 251 阅读, 0 推荐, 收藏, 编辑
摘要:This notes talks about how to Create Class Hierarchy mappings in NHibernate 阅读全文

NHibernate Notes2_Handling versioning and concurrency

2011-09-04 22:47 by 小郝(Kaibo Hao), 316 阅读, 0 推荐, 收藏, 编辑
摘要:This notes talks about the optmistic and pessmistic locking to hande versioning and cucurrency in NHibernate. 阅读全文
上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页