Clean Code – Chapter 4: Comments】的更多相关文章

“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…
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…
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…
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…
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…
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…
最近开始研读 Robert C.Martin 的 “Clean Code”,为了巩固学习,会把每一章的笔记整理到博客中.而这篇博文作为一个索引和总结,会陆续加入各章的笔记链接,以及全部读完后的心得体会. 这里也引用一下第一章中提到的 LeBlanc's law: Later equals never. 看到这句话时,脑海中想到的中文翻译居然是 “有些事现在不做,一辈子都不会做了”.所以,为了不留遗憾,开始 "clean code" 吧. 以下为各章读书笔记目录链接: Chapter 2…
原文:https://www.webcodegeeks.com/web-development/clean-code-principles-better-programmer/ ----------------------------------------------------------------- “My code is working well, the website I built is looking great, and my client is happy. So why…
Clean code 看<clean code>一书,学习高手写出的代码,简单高效的代 1.目标 Bjarne Stroustrup:优雅且高效:直截了当:减少依赖:只做好一件事 Grady booch:简单直接 Dave thomas:可读,可维护,单元测试 Ron Jeffries:不要重复.单一职责,表达力(Expressiveness) 代码的书写,一定程度上体现了编程的思想,编码者的功力,标识出红色的部分我觉得体现了函数式编程,面向对象的思想,需要细细体会 2 命名 2.1 前期统一…
@ 目录 第 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 单…