I just came back from holiday in Greece and I’ve read a couple of books there of which Clean Code is undoubtedly the most interesting one. Here is a quick summary of what the book is about.
Clean Code is guide for developers that teaches you principles of how to make your code more readable and expressive. It doesn’t really matter what language you program in as it applies on most modern OO programming languages. I really learned allot from this book. While I was reading it I was cursing myself for breaking many of the rules layout by this book. As the author of the book explains, this isn’t a feel good book that you can read once and then feel good that you’ve learned something. It’s a continuing process of improving yourself and trying to express the requirements as clean as possible in code. That is the reason that I’m planning on reading this book again, reading a chapter day by day to see what rules that I am breaking and how I can make my code more readable.
The author also does some bold things. He, for example, takes a piece of OpenSource code and starts refactoring it piece by piece to make it clean. By doing this you can see that clean code isn’t written from the first attempt but it is the process of writing dirty / “less clean” code then refining and molding it until it is readable.
The last chapter of the book covers code smells. The author admits borrowing a couple of the code smells from Refactoring of Martin Fowler. You can use this chapter as a checklist on a daily basis. Once you see yourself breaking some rules you can start thinking about what you’re doing wrong and how you can refactor.
I could write pages about the many aspects this book covers so if you’re in to a very good book for writing code, then I recommend this one! I’m also thinking about buying some of his other books like the The Clean Coder: A Code of Conduct for Professional Programmers (Robert C. Martin Series) and Agile Software Development, Principles, Patterns, and Practices
To sum it up here are some of the things that sticked into the back side of my head:
- Clean code doesn’t need allot of comments but comments itself
- To write code you need to read code, so make sure that code is expressive and easy to read
- Boy Scout Rule: Leave the campground cleaner than you found it.
- Treat your tests with the same care you treat your production code. Rotting tests will lead to rotting production code
- One assert per test
- And many many more…
Until next time ;)
Geen opmerkingen:
Een reactie posten