Clean Code – Chapter 3: Functions】的更多相关文章

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…
“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…
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…
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…
最近开始研读 Robert C.Martin 的 “Clean Code”,为了巩固学习,会把每一章的笔记整理到博客中.而这篇博文作为一个索引和总结,会陆续加入各章的笔记链接,以及全部读完后的心得体会. 这里也引用一下第一章中提到的 LeBlanc's law: Later equals never. 看到这句话时,脑海中想到的中文翻译居然是 “有些事现在不做,一辈子都不会做了”.所以,为了不留遗憾,开始 "clean code" 吧. 以下为各章读书笔记目录链接: Chapter 2…
<Clean Code>一书从翻开至今,已经差不多两个月的时间了,尽管刨去其中的假期,算下来实在是读得有点慢.阅读期间,断断续续的做了不少笔记.之前,每每在读完了一本技术书籍之后,其中的诸多细节会很快的淡忘,最终留下的往往是在阅读时候与自己之前的印象产生极大共鸣的部分,或者在之后实践当中碰巧运用到的一些知识点.所以,根据已往的经验来说,对于一本技术书籍的学习,个人更愿意依照如下两个基本原则来学习: 撷取个人当前认同最深的少数几个知识点,反复进行实践,并在理解之后再扩张到其他的知识点 择期再次阅…
原文: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…
@ 目录 第 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 单…