Working on a non-XP project recently, manual testing indicated that some code for creating PDF files was buggy -- producing incorrect output. With the various options and choices for inputs, there was about 12,000 combinations of input that could be tested. I wrote about 300 one-line tests, specifying a representative sample of various combination of inputs and the expected outputs, which would be used as input to certain functions in PDF library (I had to refactor to expose these intermediate results for unit testing). It turned out that only about 30% of the tests were passing. I commented out the function, and wrote simpler code to produce the correct outputs, using the 300 tests to measure my progress... first I had two dozen tests passing, then 50%, later still 100%. [I had to manual inspect the output PDF has the correct appearance, but once I know the output was correct, I could rely on the intermediate values for detecting regressions. Running the automated tests took 5 minutes. Trying to do the 300 tests manually would have taken a full week of work -- no wonder that the original coder, manually testing via the user-interface, didn't try a full spectrum of possible inputs to verify his or her work.
It always surprises me when I find complex lines of legacy code where the terms of the equations all cancel each other out... the equation is too complicated for the compiler to optimize-away [with partial results on various lines in various variables], but why didn't the programmer use simple algebra to see that they're just doing a complex equivalent of multiplying by one and adding zero? Test, code, refactor keeps me from doing the same, I guess. On Dec 3, 2004, at 1:34 PM, Christophe Thibaut wrote: > I work with legacy apps, some of those in which the "test-to-code" > ratio > is generally not 2:1 but rather 10:10000. Of course I'll read the > -- C. Keith Ray <http://homepage.mac.com/keithray/blog/index.html> <http://homepage.mac.com/keithray/xpminifaq.html> <http://homepage.mac.com/keithray/resume2.html> To Post a message, send it to: [EMAIL PROTECTED] To Unsubscribe, send a blank message to: [EMAIL PROTECTED] ad-free courtesy of objectmentor.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/extremeprogramming/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
