Code Smell
I just finished reading "Test-Driver Development By Example" by Kent Beck and it got me to thinking about code smell. In the book, Mr. Beck pounds the idea of test first and then remove duplication into your head. It's almost becomes like a mantra. In fact, the thought of no duplication is also the first bullet point in "The Pragmatic Programmer" and in several other books. Duplication is bad. In fact, I use duplication as a litmus test for "code smell" (I can't remember who coined this phrase, sorry!). Well, it got me thinking of what other things show code smell? I wanted to have to come up with a short list , a bare essentials if you will and I think there are only two to try to aspire to in object-oriented programming! They are no duplication (shocker, right?) and the law of demeter (read the pragmatic programmer or Smalltalk with Style for more information). If you keep these two in check, I think your code will be incredibly clean and easily maintainable for starters. Now, this might seem overetly simplistic, but it's the way you solve "code smell" to achieve these two goals that is the challenge. I wanted a nice easy to remember set of rules to guide me when I need to refactor and that I could give to fellow developers on my team. I wanted it small. Now, I'm trying my experiment out right now, so I might add to it (but, I don't want to). Test first, remove duplication, and reduce across object sends in that order. It doesn't get much easier now does it? I'll update everybody on how it works out.
Tuesday, October 28, 2003
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment