论坛首页 Java企业应用论坛

Effective Java第二版变更之 Classes and Interfaces

浏览 1376 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (9)
作者 正文
   发表时间:2009-10-06   最后修改:2009-10-21
第2版  Classes and Interfaces

Item 13: Minimize the accessibility of classes and members

Item 14: In public classes, use accessor methods, not public fields
Item14为新加的条目。

Item 15: Minimize mutability
Item15原为Favor immutability. 现在改成了Minimize mutability,覆盖的范围更广一点。

Item 16: Favor composition over inheritance

Item 17: Design and document for inheritance or else prohibit it

Item 18: Prefer interfaces to abstract classes

Item 19: Use interfaces only to define types

Item 20: Prefer class hierarchies to tagged classes
Item20为新加的条目。解释了在类的设计中引入tag field的坏处,以及如何用类的继承体系去实现相似的功能。

Item 21: Use function objects to represent strategies
Item21为新加的条目。这个条目好像意义不大,讲解了java在没有原生函数指针的情况下如何用其他手段完成函数指针的功能。

Item 22: Favor static member classes over nonstatic







论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics