…Almost. There’s a few places on the web that mention the FizzBuzz problem as a good problem to weed out useless applications for senior developer positions, citing that over 30% of university graduates can’t do this in 10 to 15 minutes. Seriously? What shoddy uni do they go to. Admittedly I’m not a graduate, but all the concepts needed to implement this in no time flat are taught in first year uni!
What’s the FizzBuzz problem? The problem goes like this: print out all the integers from 1 to 100, replacing every integer divisible by 3 with the word “Fizz”. Also replace every integer divisible by 5 with the word “Buzz”. If an integer is divisible by 3 and 5 replace it with FizzBuzz.
The module operator is the key to the solution. If a number is wholly divisible by another, it’s modulo is 0. EG 20 module 5 is 0 because 5 goes into 20 exactly 4 times.
Without further ado, here’s my 30 second solution.
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
Console.WriteLine("FizzBuzz");
else if (i % 3 == 0)
Console.WriteLine("Fizz");
else if (i % 5 == 0)
Console.WriteLine("Buzz");
else
Console.WriteLine(i);
}
See what I mean? Trivial isn’t it. FizzBuzz is ok to give people with less than 1 year experience, just to show they can cut at least some code, but it’s not at all representative of tasks a senior developer would perform.
What does a senior developer typically do?
- Write test plans
- Gather requirements
- Lead and mentor teams
- Determine architectures
- Cut code
A senior developer should at least be quizzed on patterns. I recently applied to two respectable software development companies for a senior develop position. Both required me to complete a small task prior to them even looking at my resume. This included writing test plans, and providing production ready code for a trivial application, but one that was complex enough to show knowledge and flair for development. E.G. the use of patterns, a layered architecture, use of S.O.L.I.D. principles, TDD or DDD or whatever takes your fancy. I think this approach is much more suitable for getting quality employees.