A few months ago, Brian Kotek recommended I pick up a book called "Clean Code" by Robert C. Martin. I picked it up, put it in my "To Read" queue, and promptly forgot about it for a while. Then one day I had a long plane ride coming up and as I was wrapping up another book, I threw in "Clean Code" so I'd have something to start reading. (Am I the only who absolutely fears being on a plane with nothing to do?)
Within five minutes of cracking open the book, I had dug into my backpack, brought out my pen, and was underlining madly. I had not known really want to expect, but it turns out that this is easily (for me anyway) one of the most important programming books I've read in my life.
I absolutely will not do it justice, but at a high level, the book concerns itself with the quality of the code you produce. This covers everything from variable naming, class and method structure, commenting, etc. Martin goes into a level of detail I frankly did not know was even possible. We all "know", for example, what makes up good variable naming rules, but Martin goes into the theory at a level I had not thought of before.
What makes this incredible is that after numerous chapters talking about best practices and what you should and should not do, Martin follows it up with an extremely in depth code refactoring. You see the original code and you get to follow the author's thought process as he makes changes. I'll point out that the code used in book is Java, but everything discussed is more than applicable to other languages, especially ColdFusion.
If there is one section I especially liked it was the one discussing method structure, including naming, their impact on the rest of your code, and even the number of arguments the method accepts. It really made me think that I need to reconsider how I use CFCs.
The book is not without controversy of course. Martin says right out (and more than once), that he expects you to disagree with him. I found his comments on, well, commenting, to be a bit extreme at times. I absolutely loved that section though (as a side note, it is the same reason I like listening to Rush sometimes - it's more fun to listen to someone you don't agree with!) This quote probably exemplifies Martin's core feeling on quotes: "Comments are always failures." Pretty strong, right? While he is certainly not against all code, I do think he isn't considering the situation I know others have seen - years old code that may have made perfect sense to a developer in 2002, but makes no sense 8 years later.
I strongly urge my readers to pick this up. It is not something you will likely "get" in a first reading. I'm planning on rereading it again in a few months. I'm also considering forming a presentation based on the material. But all in all I can think of no other book I'd recommend to a developer looking to raise the level of their craft.
p.s. Let me add that - in the same vein - Dan Wilson's CF Online Meetup presentation covered some of the same concepts yesterday. You can watch the streaming recording of it here.
Archived Comments
Ray, sounds like a really good read... minus the comments are always failures :) Definitely adding it to my reading queue.
I'm in the middle of this book and find that I agree with 90% - including the one on minimizing comments. He is almost demonic about making your code readable - refactoring. My to-read bookshelf now also includes Software Craftsmanship, The Pragmatic Programmer, and Joel on Software. (I know, I should have read The PP years ago...)
Here is a link to a great presentation done last month for the Vermont Software Developers Alliance (vtSDA) by Rik Dryfoos (didit.com) where he talks at length about good development practices and resources. http://www.vimeo.com/vtsda
Excellent. I'll immediately start looking for the book.
Bad side of reading material covering so "subjective" topics is that I usually piss off and tend to argue, what I can't...quite useless doing it against paper :)
I looked this up right after your recommendation during the preso yesterday. (It's on Safari for those who have access.) It is really helpful. Dan's preso was very useful too. Both will have me thinking differently while coding.
All of Robert Martin's books and articles are excellent. Visit his Object Mentor website and see for yourself. If all software were developed by following his methodologies and principles... :)
I have been reading this book and it gives very good insights into creating cleaner more organised code.
As stated, i dont always agree with what he is saying, but believe his passion for creating clean code is admirable, as so many programmers just get the code working and leave it at that.
I have picked up some good tips so far, like creating short functions which only do one thing. Only issue is that im finding it more difficult to grasp as I go through the book, so in that sense it isnt an "easy road". But this something that is proclaimed at the start of the book anyway.