Web hosting Web hosting

Friday 16 December 2016

Best Book for Writing Clean Code


While I agree with most of the answers that books are not (on their own), the best way to learn to write clean code, they are a great supplement to other things you might be doing (like reading code, getting your code reviewed, etc). If you’re anything like me, in addition to practice, you like having a broader reference where someone smart has spent a non-trivial amount of time figuring out cataloging and summarizing things. Even things that are intuitive make a lot more sense when someone has named them, structured them, etc.
Here are my favorites:
  1. Uncle Bob’s Clean Code : A very opinionated take on why writing good code matters, and what constitutes good code. It clearly documents the pitfalls of what bad code can lead to, and minces no words (“[bad code will] bring an organization to its knees” and “programmers who satisfy themselves with merely working code are behaving unprofessionally”). It covers principles, patterns,
  1. heuristics, and “smells”, and includes case studies so you can see, first-hand, how everything applies to real world situations. Most importantly, it helps frame your mind for what is, in my opinion, the most important part of writing good code: empathy (for others who will read your code, and even your future self). For instance, the “Boy Scout Rule” is a good principle to work by (“leave things in better state than you found them”). On the downsides, it is a bit less “structured” than Code Complete, but that didn’t bother me.
  2. Code Complete : I was given a copy of this on my first day of work at Google. This is the definitive guide on writing code. The first downside, however, is its length (it’s about 900 pages long, and took me about a year to get through). It is also a bit dated. Don’t get me wrong, most of these principles are universal, but over time the software development process has adapted, and subtle tradeoffs like maintainability vs. speed can change. So I’d definitely start with Clean Code first.
It was once described to me that Code Complete is the Bible, and Clean Code is the handbook. If you’re just getting started, I’d start with the handbook.
A final note: A lot of people will point out that most of the content in these books is obvious and intuitive, but at the end of the day, a lot of times the problem isn’t not knowing, it’s not reminding. I’ve seen a lot of experienced developers (including myself) make bad trade-offs.

No comments:

Post a Comment

Web hosting