« Kata Five - Bloom Filters | Main | Kata Three: How Big, How Fast? »

January 28, 2007

Kata Four: Data Munging

Martin Fowler gave me a hard time for KataTwo, complaining that it was yet another single-function, academic exercise. Which, or course, it was. So this week let’s mix things up a bit.

Here’s an exercise in three parts to do with real world data. Try hard not to read ahead—do each part in turn.

Part One: Weather Data

In weather.dat you’ll find daily weather data for Morristown, NJ for June 2002. Download this text file, then write a program to output the day number (column one) with the smallest temperature spread (the maximum temperature is the second column, the minimum the third column).

Part Two: Soccer League Table

The file football.dat contains the results from the English Premier League for 2001/2. The columns labeled ‘F’ and ‘A’ contain the total number of goals scored for and against each team in that season (so Arsenal scored 79 goals against opponents, and had 36 goals scored against them). Write a program to print the name of the team with the smallest difference in ‘for’ and ‘against’ goals.

Part Three: DRY Fusion

Take the two programs written previously and factor out as much common code as possible, leaving you with two smaller programs and some kind of shared functionality.

Kata Questions

  • To what extent did the design decisions you made when writing the original programs make it easier or harder to factor out common code?
  • Was the way you wrote the second program influenced by writing the first?
  • Is factoring out as much common code as possible always a good thing? Did the readability of the programs suffer because of this requirement? How about the maintainability?

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/2226312/7680045

Listed below are links to weblogs that reference Kata Four: Data Munging:

» Dojo IX from Jabbering Giraffe
Last night was the latest Coding Dojo. It was an astonishing success. Not only did we all manage to enjoy ourselves, we actually produced some working code! We were attempting Kata Four (data munging), which is split into three parts. Admittedly, we only [Read More]

» Coding Dojo 9 from Jabbering Giraffe
Im just back from Dojo#9. We attempted Kata 4 again, but in Ruby this time. Even though I was the only one with much Ruby experience behind me, it still wasnt much of a problem in practise. I did some cheat sheets, but they didnt seem [Read More]

Comments

OT: The headings "D" and "L" are the wrong way around in the football table. It's 3 points for a win, 1 for a draw and none for a loss.

That is a nice Task, I solved it with Groovy in 12 lines clean code. But the logic was mabye too easy.

Post a comment

If you have a TypeKey or TypePad account, please Sign In