This chapter focuses on some of the authors’ own thoughts and understandings about writing code, and what they want to say to us. I’ve talked a little bit about the consequences of bad code, and then I’ve talked about the benefits of good code.

1. What is code

Specifying requirements to a level of detail that a machine can execute is what programming does, and this specification is called code.

2. The cost of chaos

Lebron’s law: Later is never

  • 1. Some teams make rapid progress in the early stages of a project and then slow down for a year or two. Every change to your code affects two or three other pieces of code
  • 2. Taking the time to keep your code clean is not just about productivity, it’s about survival
  • 3. It is also unprofessional for programmers to comply without understanding the wishes of chaos risk managers

3. What is clean code

Bjarne Stroustrup, C++ inventor: I like elegant and efficient code. The code logic should be straightforward so that bugs are hard to hide; Minimize dependencies and make them easy to maintain; Refine error-handling code according to a hierarchical strategy; Optimize performance to avoid tempting others to do unruly optimization and create a mess. Clean code does only one thing.


Grady Booch, For Analysis and Design: Clean code is simple and straightforward. Clean code is like good prose. Clean code never hides the designer’s intent, full of neat abstractions and straightforward control statements.


Dave Thomas, FOUNDER, OTI: Clean code should be readable and supplemented by developers other than the author. It should have unit tests and acceptance tests. It uses meaningful names. It provides one way to do one thing instead of many. It has as few dependencies as possible, and clearly defines and provides a clear, minimal API. Code should express meaning literally, because different languages mean that not all necessary information can be clearly expressed in the code itself.


Michael Feathers, “The Art of Tinkering with Code” : I could list all the things I’ve noticed about clean code, but there’s one that’s fundamental. Clean code always looks like it was written by someone who cares. There is little room for improvement. A code writer has thought of everything, and if you try to improve it, you’ll always come back to admiring the code someone left you — the code someone dedicated to it.


Ron Jeffries, Extreme Programming Implementation: Simple code, in order of importance: passes all tests; No duplicate code; Reflect all the design concepts in the system; Include as few entities as possible, such as classes, methods, functions, etc


Ward Cunningham, Wiki inventor: Clean code if every routine feels right to you. Code is beautiful if it makes the programming language look like it exists to solve that problem.

3. Read/write ratio in programming

1. The ratio of reading time to writing time is more than 10:1

4. Boy Scout rules

“Leave the camp cleaner than when you came.”

5. To summarize

  • The only way to meet deadlines: always keep your code as clean as possible.
  • Clean code does only one thing.
  • Don’t repeat code, just do one thing, express power, small scale abstraction.
  • If you want to do it fast, if you want to do it fast, if you want to write code easily, make it easy to read.
  • If your code is cleaner every time you check in than it was when you checked out, then your code won’t corrupt

Pay attention to the public account “Programmer interview”

Reply to “interview” to get interview package!!

This public account to share their own from programmer xiao Bai to experience spring recruitment autumn recruitment cut more than 10 offer interview written test experience, including [Java], [operating system], [computer network], [design mode], [data structure and algorithm], [Dacheng face by], [database] look forward to you join!!

1. Computer network —- Three times shake hands four times wave hands

2. Dream come true —– Project self-introduction

Here are the design patterns you asked for

4. Shocked! Check out this programmer interview manual!!

5. Teach you the interview “Profile” word for word

6. Nearly 30 interviews shared