How we ran our Legacy Code Retreat

Preparation:

The Content:

The Organization:

We had the great opportunity to use our employer’s facilities. Everything is available there, except for food. So the only thing left to do was to get some food. We have chosen our local bakery for breakfast, got fruit at the supermarket and hired a caterer for lunch.
What we learned: Don’t buy too much food. – We did. For the bakery we discovered that three pieces per participant are sufficient, and two pieces of fruit. We made an effort to offer food of excellent quality, and many participants rewarded this with small remarks about how much they enjoyed it.
We had coffee prepared for every break. During the setting up, we could count on the earlycomers’ aid in carrying stuff around. It is our general experience that participants of those kinds of events are always very helpful.

The iterations:

In gerenal the format worked well. The first iteration served as warm-up. We stretched the second iteration to another 45 minutes to give the participants the chance to play around more. The restriction-based iterations have been sort of confusing for some of the participants. Their feedback indicates that the codebase is not very suitable for applying the proposed patterns. We should have given a little bit more guidance there and clearly explain that the restrictions are not exercises to be completed but rather propositions to serve as a mental guide for the modifications to be done and to play around with.

A Great Surprise:

The biggest surprise we’ve experienced was that one of the participants (Hayati Ayguen) came up with doing the golden master and the automated comparison via a bash-script (see below)! Great!

Summary:

This won’t be the last legacy code retreat in Germany. Be prepared to see more of them in the future. Feel free to contact us for help when you want to run your own.

Bash Scripts and related Code:

createGoldenMaster.sh

#!/bin/bash

for s in `seq 1 $1`; do
  ./a.out $s >erg$s
done

compareWithGoldenMaster.sh

#!/bin/bash

totalerrs=0
for s in `seq 1 10`; do
  ./a.out $s >current
  errs=`diff erg$s current |wc -l`
  echo "vergleich $s hat " $errs "unterschiede"
  totalerrs=$[ $totalerrs + $errs ]
done

if [ $totalerrs -eq 0 ]; then
  echo all OK.
else 
  echo ERROR!
fi

GameRunner.cpp

#include <stdlib.h>
#include "Game.h"

static bool notAWinner;

int main( int argc, char * argv[] )
{
    if ( argc != 2 )
    {
        cerr << "usage: " << argv[0] << " <seed>" << endl
             << "  seed should integer " << endl;
        return 10;
    }
    int seed = atoi( argv[1] );
    cout << "seed is " << seed << endl;
    srand( seed );

	Game aGame;

	aGame.add("Chet");
	aGame.add("Pat");
	aGame.add("Sue");

	do
	{
		aGame.roll(rand() % 5 + 1);

		if (rand() % 9 == 7)
		{
			notAWinner = aGame.wrongAnswer();
		}
		else
		{
			notAWinner = aGame.wasCorrectlyAnswered();
		}
	} while (notAWinner);

}
About these ads

One thought on “How we ran our Legacy Code Retreat

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s