Classes
摘要:Class Organization Following the standard Java convention, a class should begin with a list of variables.Public static constants, if any, should come
阅读全文
Unit Tests
摘要:The Three Laws of TDD First Law : you may not write production code until you have written a failing unit test. Second Law : you may not write more of
阅读全文
Boundaries
摘要:Using Third-Party Code There is a natural tension between the provider of an interface and the user of an interface.Providers of third-party packages
阅读全文
Error Handling
摘要:Use Exceptions Rather Than Return Codes Back in the distant past there were many languages that didn't have exceptions.In those languages the techniqu
阅读全文
Objects and Data Structures
摘要:Date Abstraction Hiding implementation is not just a matter of putting a layer of fucntions between the variables.Hiding implementation is about abstr
阅读全文
Comments
摘要:Nothing can be quite so helpful as a well-placed comment.Nothing can clutter up a module more than frivolous dogmatic comments.Nothing can be quite so
阅读全文
Functions
摘要:Small The first rule of functions is that they should be small.The second rule of functions is that they should be smaller than that.Functions should
阅读全文
有意义的命名 Meaningful names
摘要:名副其实 use intention-revealing names 变量、函数或类的名称应该已经答复了所有的大问题。它该告诉你,他为什么会存在,他做什么事,应该怎么用。我们应该选择都是致命了计量对象单位的名称。 避免误导 avoid disinformation 必修避免留下演示代码本意的错误线索
阅读全文
整洁代码
摘要:TPM(Total Productive Maintenance)主要支柱之一为5S原则体系。5S哲学包括以下概念:整理(Seiri),或谓组织、整顿(Seiton),或谓整齐、清楚(Seiso)或谓清洁、清洁(Seiketsu)或谓标准化、身美(Shitsuke)或谓纪律。 整洁的代码应可由...
阅读全文