Writing Clean Code
2 minute read
One of my favorite books on programming so far has been Clean Code: A Handbook of Agile Software Craftsmanship (Get it here). It’s full of great wisdom on writing–you guessed it–clean code. Clean code not only makes your life better, but it will save your friends and teammates hours of headaches. And perhaps even more importantly, it reflects a care for craft and excellence in your work.
Anyways, enough from me; here’s a few great quotes from a few greats on writing clean code:
I could list all the qualities that I notice in clean code, but there is one overarching quality that leads to all of them. Clean code always looks like it was written by someone who cares. There is nothing obvious that you can do to make it better. All of those things were thought about by the code’s author, and if you try to imagine improvements, you’re led back to where you are, sitting in appreciation of the code someone left for you—code left by someone who cares deeply about the craft. 1
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. 2
Clean code can be read, and enhnced by a developer other than its original author. It has unit and acceptance tests. It has meaningful anmes. It provides one way rather than many ways for doing one thing. It has minimal dependencies, which are explicitly defined, and provides a clear and minimal API. Code should be literate since depending on the language, not all necessary information can be expressed clearly in code alone. 3
…And now we all feel guilty about our code. Excellent.
1,2,3 (p.8-10, respectively) Martin, Robert C. Clean Code: A Handbook of Agile Software Craftsmanship. Upper Saddle River, NJ: Prentice Hall, 2009. Print.