|
|
Teststands for Exploratory code
Create a new, empty project. Set it up as you like it, so it's easy for you to use. Include your favorite libraries, and turn off the optimizers (which slow down compilation and make low-level debugging more difficult). Now leave it, empty, sitting there. This is your teststand. Your teststand is your sandbox. Your scratchpad. Your playpen. Teststands are handy because they're not involved with your "serious", real project. They're stand-alone. You can afford to royally screw-up in your teststand without taking a hit on your real project. However, the opposite is thankfully not true -- you can copy the "wins" from your teststand and plop them into your real project. So, the next time you run into an area of a language you don't completely understand, you can quickly open up your teststand and write some exploratory code. This might sound somewhat "unprofessional" -- you should look up the standards document of your language for the answer. Actually, I've found it better to go ahead and write the test code to discover the answer for yourself. Reasons:
This doesn't preclude going to the "official standard" (if one even exists for your language!), but it puts you in a stronger position of understanding if you do. Teststands are also handy for drafting, refactoring and verifying tricky code. Reviewing my C teststand (I never throw away my teststand code, I just push it aside and move ahead), I learned I've used it to:
Interestingly, in my Java teststand, I see most of my code revolves around string manipulation. Specifically, making sure I get all the zero-based index math right, especially in edge cases. I find when I move code "wins" from the teststand into the real project, I replicate the edge cases using unit testing. A concept related to teststands are spikes. I also use spikes all the time. Indeed, it's how I learned WebObjects. This was back in the 4.5 days, when documentation was scant and books nonexistent. So I wrote spike after spike after spike, for three weeks. Perhaps somewhat inefficient, but it really helped me understand the product. I view spikes as different from teststands in terms of size. I tend to create a new project for each spike I write. So, when dealing with a fragment or two of code, I use the teststand. If it's something more, I use a spike. Thursday, March 27, 2003
|
Contact Me Topics RSS Feed Linkblog
Bill Bumgarner Brent Simmons Daniel Jalkut Dave Dribin Eric Albert Eric Rescorla Eric Sink Greg Miller Gus Mueller Jeremy Zawodny John Gruber Mark Dalrymple Michael Tsai Peter Ammon Raymond Chen Ryan Wilcox Scott Stevenson Steven Frank The Daily WTF we hates software Wil Shipley |
Copyright © 1997-2008 Jonathan 'Wolf' Rentzsch. All rights reserved.
Questions? Comments? Contact Me.