Practical uses for FizzBuzz Part 1

In the Army, there were generally questions about soldiering that personnel looking for promotion would be asked. They would spend a day going before a promotion board in their crisp uniform and be asked questions about being a soldier.  Questions like: What are the different MOPP Levels? What is the process for clearing a weapon jam in an M16?  What is the effective range of a M16? What is “Danger close” for an MLRS? 

In case you were wondering, “Danger Close” for an MLRS is a whopping 1km x 1km.

Sadly, software development doesn’t let me ask such cool questions. I have to stick with things like “What is inheritance and what is composition, and when would I use either?”

However, much like the questions the Army promotion boards ask, these questions we ask developers are just as useless.  A great soldier may not know the effective range of an M16, but he can hit what he can see — and that’s even better.

A software developer may not know the word ‘composition’, but they recognize bad design when they see it; and they recognize good design when they see it.

This makes a change of tactics necessary, as it were.

Don’t ask questions about Object Oriented design — have the candidate design something for you.  Don’t ask questions about code — have the developer write code for you.

 

The easiest way to do the first is to use something like Monopoly to conduct the interview. To do the second? Something like Fizzbuzz would do just as well.

 

The great thing about Fizzbuzz (even though it’s shockingly simple) is that it can serve to show a few things:

1. Does the candidate know the language? (If someone is using ‘Mod’ in C#, that’s a good sign they don’t really work in that language much (which is doubly disconcerting if the word ‘Expert’ is next to ‘C#’ on their resume)

2. How do they structure their code? Do they go for the elegant solution? The Simple solution?

3. It provides a basis for refactoring. This shows you if they can think about the potential problems in their code.

 

    for (int i = 1; i <= 100; i++)
{
string result = String.Empty;
if (i % 3 == 0)
result += "fizz";
if (i % 5 == 0)
result += "buzz";
if (result == String.Empty)
result = i.ToString();
Console.WriteLine(result);
}

In our next wonderful adventure, I’ll go into how to use a simple programming exercise to determine a candidate’s ability.

Leave a Reply