Monday, April 26, 2010

Tidy

Normally, we run two versions of our software in the general lab pool at any point in time:
  • HEAD. The unstable, next generation stuff.
  • RELEASE. The stable version that's going out next or is just out.
Other things - experiments, prototypes, patches on older branches, etc. - are done on separate branches, but for the most part they don't run in the general lab pool. Because we have these two main items running in the pool, many of our utilities differentiate between head and release. This allows us to graph performance results on head separately from on release, for example.

All good so far.

But.

We've recently decided to run two releases simultaneously for some things. So now our lab pool looks like this:
  • HEAD. The unstable, next generation stuff.
  • BRANCH-A. The stable version that's going out next or is just out.
  • BRANCH-B. The stable version going out just after branch A.
This means we need to update various utilities, graphing tools, etc. to handle two releases instead of one. The simple way to do this would be to do it in an additive manner.

Our test reporting tool used to look like this, for example:

if (head) {
do stuff
elsif (release) {
do other stuff
else {
you must be doing one of your wacky side projects
}

I could have done the simple cheating thing and made it look like this:

if (head) {
do stuff
elsif (release) {
do BRANCH A stuff
elsif (branch B) {
do BRANCH B stuff
else {
you must be doing one of your wacky side projects
}

It would have worked just fine. It would have been wrong.

When you're working in code, keep it tidy. Yes, test code, too.

I made it look like this:
if (head) {
do stuff
elsif (branch A) {
do BRANCH A stuff
elsif (branch B) {
do BRANCH B stuff
elsif (release) {
notify QA we missed a spot
else {
you must be doing one of your wacky side projects
}

That's tidier. I also added a todo and will go back in about a week and get rid of that release clause, because by then I'll know if we've missed anything.

Yes, it's test code. That's no reason to not be tidy about changing it. Keep your code clean, in test just as you do in the product.

No comments:

Post a Comment