Beavis was fixing a bug where the header in a mail merge didn’t display the correct label. Each country has a different name for their Identification numbers. The data was correct, but the label always showed the English name.
He comes up with a fix where he checks if the region is Scotland or Wales, otherwise he returns the English label. What about Ireland? The bug still remains. What about other countries we support in the future? This will require a further change to this code.
He takes the text from a resource file which is fine. He wrote some unit tests which covered his few scenarios. However, he was comparing the returned value to the text from the resource file. This means if someone accidentally changes the text in the resource file, then runs the tests; it will still pass. The tests should have been written with hard-coded text so isn’t so coupled to the actual implementation.
When it was submitted to review, the Lead Developer comments that it doesn’t fix all scenarios. He also made a brilliant point about another aspect of Beavis’ code. He was taking the customer’s information from the currently selected customer. This is mail merge. Mail merges are often done in batches. There isn’t just one selected customer, but a list of them. This could take the wrong person’s data.
A few days later, Beavis finally came up with the expected solution. The next day, it still isn’t checked in, and his update was along the lines of “I’m updating my branch”, which should only take a minute, not the entire day. I checked the history of the Bug. It has taken him 2 weeks, when I reckon I would have completed it in a day.
Later on, I overhear a Lead Developer express his concern to a manager that Beavis had been really slow and hadn’t showed any thought or care about his work.
It’s nice that it has been flagged as an issue.