Monday, 15 December 2008

Scaffold

Ever find yourself commenting out lines of code, or adding dummy values, or setting up variables just to test something, then once the test has finished, going back through your code removing the comments, commenting out the dummy values and changing the variables back? And then repeating that sequence when you find that you hadn't actually finished testing?

I do.

Steve McConnell calls this code "scaffolding code".

I also have a tendency to forget to remove this code once I've fixed my bug or finished my test. So I've gotten into the habit of marking the change with a comment similar to

// Scaffold: added dummy value
int dummy = 3;


Sometimes my scaffold comments get lost among a sea of other code, and I forget to remove it. So to group it together, I've started using a single scaffold file / class. That way there's only one place to look for the scaffold code.

That's still susceptible to me forgetting about the scaffold before publishing my program, so I think the next step might be to create a user defined scaffold file that can be edited and stored locally, so even if I turn on all my scaffold constructs, nobody else sees them.

No comments: