ArticleS
.
MichaelFeathers
.
BeforeClarity
Edit Page:
!title Before Clarity Late last year I wrote an article for Martin Fowler's Design Column in IEEE Software magazine. The topic was clarity in code. Personally, I feel that clarity is one of the most important attributes a piece of code can have. Yet, I often find myself very deliberately sacrificing it. Enticed? Here's a link to the article: http://www.objectmentor.com/resources/articles/beforeClarity.pdf What do you think? ---- !commentForm !* , , , Hi everyone, I like the way Michael compares a rigid piece of legacy code to an ill human being (Working Effectively With Legacy Code). What he's saying is that the net effect of an not so esthetic refactoring lies in the new opportunities that it brings along, just like in surgery. But not-agile people that got used to work with an old (odd?) programming style will tend to recreate it over and over again. Or when they find a piece of code written in a way, they will stick to it. Am I wrong ? And when they see what agilists are doing with legacy code, they turn red and get skeptic. They would expect agile progammers to make the code easier to understand. Agility doesn't come for free :/ *! !* Sat, 2 Apr 2005 08:57:46, MichaelFeathers, Well, we do make the code easier to understand, the tests help with that. The structure might get a little funky, though. It is kind of like surgery. To make a change, you often have to leave a scar, but everything beneath it can get better. *! !* Tue, 5 Apr 2005 03:50:38, IsmetKahraman, For the time being, I am reading your excellent book "Working Effectively With Legacy Code". This thread might be an appropriate place to talk about it. You are mentioning about class dependencies and managing these dependencies in order to put every single class with its own into a test harness. What we are ending up is a strange animal, inheritance hierarchies with the sole purpose of testing, means no classification. Here is the question, do you mean with "class" a "class category"(more than one related classes) that is to be put into a test harness? And I have to mention it here that "seam" concept or metaphor is really a great approach, I enjoyed it much. Told friends of mine, and we totally agree that it gives a deep insight. *! !* Tue, 5 Apr 2005 05:55:28, Laurent Decorps, I'm too a great fan of this book. I read tens of book in the agile field : this one is the only one helpfull if you don't start from scratch (with refactoring to patterns, well, ok ...). You (michael) put incredibly sound best pratices in a simple manner as to how to put testing in place. As simple as that : how to put tests at work. I'm currently working on WBI Crossworlds EAI : it generates ugly java classes ... with your advices, I can put my generated classes in a test harness. I can even use them in Fitness :) what a tea *! !* Tue, 5 Apr 2005 06:03:13, Laurent Decorps, oops, sorry :) what a teaM here at Object Mentor : keep up the good work ! *! !* Thu, 7 Apr 2005 17:31:37, MichaelFeathers, Thanks very much for the compliments. Ismet, yes, often I advocate using inheritance to get access in testing, but I really push naming conventions, like the ones I use in my book in ''Chapter 18: My Test Code Is In The Way''. They really make the distinction between production code and test code clearer. Aside from that, there are many ways of testing that don't involve inheritance. Was I answering the right question? *! !* Wed, 15 Jun 2005 17:14:14, Kenneth Kasajian, Working Effectively With Legacy Code Are there e-book versions of "Working Effectively With Legacy Code" available? The reason we want an electronic version is so that we can send it to our India office. It's very expensive to buy books there and it's not in print in India. If there were an electronic version, we would likely purchase a bunch of copies for our developers there. ''Ken, I don't think there is. It's on Safari, though, if I remember correctly. -- MichaelFeathers'' *!
Hints:
Use alt+s (Windows) or control+s (Mac OS X) to save your changes. Or, tab from the text area to the "Save" button!
Grab the lower-right corner of the text area to increase its size (works with some browsers).