摘要:
This post introduces the benefits of the Declaring Dependencies on the top of the function or module. 阅读全文
阅读排行榜
Effective Java 20 Prefer class hierarchies to tagged classes
2014-03-15 09:56 by 小郝(Kaibo Hao), 365 阅读, 收藏,
摘要:
If you're tempted to write a class with an explicit tag field, think about whether the tag could be eliminated and the class replaced by a hierarchy. When you encounter an existing class with a tag field, consider refactoring it into a hierarchy. 阅读全文
Effective Java 52 Refer to objects by their interfaces
2014-04-15 22:01 by 小郝(Kaibo Hao), 364 阅读, 收藏,
摘要:
In practice, it depends whether a given object has an appropriate interface. If it does, your program will be more flexible if you use the interface to refer to the object; if not, just use the least specific class in the class hierarchy that provides the required functionality. 阅读全文
Java Concurrency In Practice -Chapter 2 Thread Safety
2014-05-16 20:03 by 小郝(Kaibo Hao), 360 阅读, 收藏,
摘要:
This post introduces the challenge and related solution (Atomic, Locks) on Thread Safety. 阅读全文
Effective Java 51 Beware the performance of string concatenation
2014-04-14 10:47 by 小郝(Kaibo Hao), 358 阅读, 收藏,
摘要:
Don't use the string concatenation operator to combine more than a few strings unless performance is irrelevant. Use StringBuilder's append method instead. Alternatively, use a character array, or process the strings one at a time instead of combining them. 阅读全文
JavaScript Patterns 2.5 (Not) Augmenting Build-in Prototypes
2014-05-20 13:36 by 小郝(Kaibo Hao), 354 阅读, 收藏,
摘要:
Other developers using your code will probably expect the built-in JavaScript methods to work consistently and will not expect your additions. And properties you add to the prototype may show up in loops that don't use hasOwnProperty(), so they can create confusion.Please be cautious of Augmenting Build-in Prototypes. 阅读全文
Effective Java 62 Document all exceptions thrown by each method
2014-04-26 21:03 by 小郝(Kaibo Hao), 349 阅读, 收藏,
摘要:
Document every exception that can be thrown by each method that you write. This is true for unchecked as well as checked exceptions, and for abstract as well as concrete methods. Provide individual throws clauses for each checked exception and do not provide throws clauses for unchecked exceptions. If you fail to document the exceptions that your methods can throw, it will be difficult or impossible for others to make effective use of your classes and interfaces. 阅读全文
Effective Java 46 Prefer for-each loops to traditional for loops
2014-04-09 08:01 by 小郝(Kaibo Hao), 349 阅读, 收藏,
摘要:
The for-each loop provides compelling advantages over the traditional for loop in clarity and bug prevention, with no performance penalty. You should use it wherever you can. 阅读全文
Effective Java 02 Consider a builder when faced with many constructor parameters
2014-02-24 10:06 by 小郝(Kaibo Hao), 348 阅读, 收藏,
摘要:
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 C# 学习笔记(三十二)避免使用ICloneable接口
2011-07-17 23:34 by 小郝(Kaibo Hao), 347 阅读, 收藏,
摘要:
实现ICloneabl接口听起来很美,不是么?还真不是,你要是为某个类实现了ICloneable接口,你就得为它的子类和相关的深拷贝和浅拷贝担心,注意每一属性的可被复制的深浅及其被复制的必要性。这看起来是多么大的一个工程,也许远远超出你的想象。 阅读全文
浙公网安备 33010602011771号