Data Abstraction Hiding implementation Data/Object Anti-Symmetry Objects hide their data behind abstractions and expose function that operate on that data. Data structure expose their data and hava no meaningful functions. Procedural code(code using…
Date Abstraction Hiding implementation is not just a matter of putting a layer of fucntions between the variables.Hiding implementation is about abstractions!A class does not simply push its varivables out through getters and setters.Rather it expose…
Small Blocks and Indenting The blocks within if statements, else statements, while statements, and so on should be one line long. Probably that line should be a function call. Functions shouldn't be large enough to hold nested structures. The indent…
Error handling is important, but if it obscures logic, it's wrong. Use Exceptions Rather Than Return Codes Separate the normal operations with error handlings. e.g. Bad code: public class DeviceController { ... public void sendShutDown() { DeviceHand…
“Don’t comment bad code—rewrite it.”——Brian W.Kernighan and P.J.Plaugher The proper use of comments is to compensate for our failure to express ourself in code. Truth can only be found in one place: the code. Comments Do Not Make Up for Bad Code Rath…
Use Intention-Revealing Names The name should tell you why it exists, what it does, and how it is used. e.g. Bad code: public List<int[]> getThem(){ List<int[]> list1 = new ArrayList<int[]>(); for (int[] x : theList) if (x[0] == 4) list1…
The Purpose of Formatting Code formatting is about communication, and communication is the professional developer's first order of business. Vertical Formatting File size: less than 200~500 lines. The Newspaper Metaphor We would like a source file to…
@ 目录 第 1 章 Clean Code 整洁代码(3星) ?为什么要整洁的代码 ?什么叫做整洁代码 第 2 章 Meaningful Names 有意义的命名(3星) 第 3 章 Functions 函数(3星) 第 4 章 Comments 注释(2星) 第 5 章 Formatting 格式 (1星) 第 6 章 Objects and Data Structures 对象和数据结构(4星) 第 7 章 Error Handling 错误处理(4星) 第 9 章 Unit Tests 单…
"I worked up a full implementation as well but I decided that it was too complicated to post in the blog. What I was really trying to get across was that immutable data structures were possible and not that hard; a full-on finger tree implementation…
  Data structures A data structure is a group of data elements grouped together under one name. These data elements, known asmembers, can have different types and different lengths. Data structures can be declared in C++ using the following syntax: s…