Tuesday, September 16, 2008 6:41 PM
I recently battled brittleness of a test project I created to provide some demo data and charting for a customer. I would make a change to one section and then duplicate (yes, I said it) to the other demos.
This went on for a couple of days due to me justifying that it was just a demo. I finally had had enough and questioned "Why am I doing this?" only to find that I had let fear of refactoring control me. I was shamed into admitting that I fell into the same trap that I chastise others about. So I found a good article (link http://www.infoq.com/articles/RefactoringMyths) and decided to comment on a few points to make myself feel better.
Refactoring can be applied as a separate stage in development process and performed by separate team I have mixed feelings concerning this point. I for one thoroughly enjoy refactoring another devs code especially when I know little about it. As to it being a separate stage of the process, I am not sure. A few shops make statements that they perform code reviews. I have only witnessed code reviews as a tool for HR, nothing more.
Not relying on comments can't be right I must agree with the author... I hate writing comments and only do so when absolutely necessary depending on if I am trying to demonstrate a better way to do something for junior programmers or using a new technique that I know has not been used in any other codebase. If a developer cannot understand what my code is doing by 'reading' it, then I have failed to hold up my end.
To take the comment thing further, I contend that once you start heavily refactoring the comments become meaningless and should be deleted. I even struggle with triple slash comments becoming out of date so I simply remove them. Granted, my work currently is not framework creation or maintenance.
I had added some comments above a different way to perform CRUD operations against a database for some of my fellow devs in code. After I did so, I had a question along the lines of 'hey, why doesn't this work. I followed your comment'. I looked at the code in question and yes my comment was followed to the letter. The problem was that the signature of the particular method they were trying to use was wrong.
So where do comments cripple people from taking the step of actually learning what they are attempting to use?
rusty