I've just read Robert C. Martin's Clean Code and Kent Beck's Implementation Patterns back to back. I actually picked up Clean Code first because my colleagues were raving about it. But then Robert Martin's book quotes from Kent Beck's book on the third page of the first chapter already, and disagrees with the quote, so I decided it'd be fun to read Implementation Patterns too. ![]()
One nice advantage of following these patterns or heuristics is that it allows you to do away with a lot of comments. Comments that are sometimes redundant, that are bound to become obsolete, and that may even misguide the reader if not properly maintained. Having learned to program in the late eighties (when writing comments was what a good programmer was supposed to do), this felt a bit strange at first. But now, when I feel the need to explain a block of code by starting a comment, I know that I need to extract that block into a separate method.
Filed under Architecture, Hibernate, Java, Testing | 11 Comments »
Nice article mate! Patterns should be used carefully though, and not artificially bloat the whole architecture.
I have read IP twice and am having trouble slogging through CC (but then, I have the paper version of IP and only the online version of CC).
I think IP changed the way I code simply because at one point Beck talks about code symmetry.
For me, this was the first time I have seen code symmetry articulated, but I think when we look at asymmetric code we notice that “something is wrong”, even if we don’t know what it is.
For me this was the “big new thing” of the book and I am encouraging my co-workers to read the book, just to have the concept explained (in hopes that we start to write more symmetric code).
cheers.
Really enjoyed this article. In fact I just ordered both books; I should be able to get a real interesting and informative presentation for our professional circle from them.
@John K Patrick: the “patterns” referred to here are not “design patterns”.
One more point. The more we try to write clean code (i.e. short methods that do exactly one thing), the more our code files can become a big mess of methods (in my IDE I don’t even have a way to know that a method is never called (even a private one!).
IDEs generally provide “extract method” tools, but mine (Visual Studio) does not offer any tools to reorganize the code. Result, the code file is a stream of consciousness mess of short methods.
So, I think tool providers have to start looking at doing method extraction with code reorganization in mind if we are ever to truely exploit the techniques of CC and IP.
In addition, as we start “sorting” methods, we will also have problems with source code systems that will be continually finding change conflicts. So SCM tools have to start having method granularity rather than just code file granulatiry.
So I think if we are to adopt some of these techniques, the tool providers have to start inventing new tools that will help us structure code files more easily.
I just read Clean Code: A Handbook of Agile Software Craftsmanship, and I must say, Chapter 17. Smells and Heuristics is the most awesome chapter I have ever read!
Thank you for introducing me to such a good book.
[...] Clean Code vs. Implementation Patterns | Xebia Blog (Code,Refactoring,Book,Comparison,SoftwareDevelo… [...]
Thanks for comparison. I’m mostly through CC. Haven’t read IP yet, and I’m wondering if I need to bother. Based on the 3 examples you gave — “Choose Descriptive Names” (CC) vs. “Intention-Revealing Name” (IP), “Functions Should Descend Only One Level of Abstraction” (CC) vs. “Composed Method” (IP), and “Use Explanatory Variables” (CC) vs. “Role-Suggesting Name” (IP) — it seems like Martin’s CC book is more plain-spoken and therefore easier to grok. If I don’t have any questions after reading CC, will reading IP add anything? (Hmm, perhaps even if not, I should read IP anyway, just so I can communicate with other programmers who have read IP but not CC.)
[...] For review please feel free to have a look at this Book Review and also very interesting comparison Clean Code vs. Implementation Pattern. And certainly few more enthusiastic who even say Get it. Read it. Learn it. Then live [...]
Thanks for an interesting comparison.
About the two books not covering how to deal with exiting code: You might find Michael Feathers Working Effectively with Legacy Code interesting. I think it’s very, very good.
@Christian: Thanks for the tip. I’ve heard more people mention that Michael Feathers’ book is an interesting one. I’ll put it on my to-read list!