From: Jim McMaster Date: 2005-12-22T08:39:23+09:00 Subject: Re: unit tests == ugly code? On Wednesday, December 21, 2005 4:30 PM, Joe Van Dyk wrote: > I've found that when I write the tests first, and then write the code, > I'm not very concerned about what the code looks like. When the code > passes the test, I drink a beer and party, then move on to the next test. > > In practice, this means that I'm using a lot of ugly regex's, poorly > named variables, and so on. I'd be more concerned about the > readability of the code if there wasn't unit tests behind it. I'm > generally in a rush to finish whatever I'm doing, and figure that > since I have a bunch of tests, refactoring stuff later won't be a big > deal. > > Anyone else out there like me? Or should I be anal about writing good > code even with the tests? I guess that would be ideal, but I'd rather > get the functionality done first. > > Joe As soon as the code passes the test, you should look for opportunities to make your code better. Failing to do so is an option, but you should recognize you are piling up a "technical debt" if you choose it. This debt ultimately will cause you grief, just as piling up debt on a credit card without paying will eventually cause you financial grief. -- Jim McMaster mailto:jim.mcmaster@comcast.net