Focal length:31.9
Exposure:1/640 sec
F number:f/5
ISO:100

Why FizzBuzz matters

If you are not working in the IT industry, chances are that you have never heard about the FizzBuzz test. In short, it is used to differentiate between bad programmers (and software architects) and potentially good programers (and software architects). Curious how the test looks like? Here it is:

“Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.”

This test should matter to you if you are a software developer or architect, or if you are hiring one. If you are the former, you should obviously pass this test. If you do not, well, maybe you should consider doing something else for a living, because writing and/or architecting software will be a struggle. If you are hiring developers and/or architects, my advice is to require anyone you hire to pass this test. Especially architects. Because this test is not about programming. Writing the lines of code is trivial. The FizzBuzz test is about thinking. It gives an answer to the question “Do you have the thinking required to architect and write good code?”

Lets analyse the FizzBuzz problem a little bit: you are given two independent boolean conditions (“number divisible with 3” and “number divisible with 5”) which give 22 cases. And for each case (combination of condition values) there is a separate output to write, in total 4 outputs. So nothing complicated.

I was recently writing an audiobook mobile application1, as a subcontracting project, for a client. At some point I had to show on the screen a list of books the user has. But what was to be shown, for each book, was depending on 4 variables:

  1. if the device is online or offline
  2. if the application runs as a native application on the device (Cordova) or it is running in a web browser
  3. if the current book has available all the information about all chapters, or if some of this information still needs to be downloaded
  4. if the book media (audio files) have been downloaded on the device or not.

All in all, we have 24=16 cases. But are all these variables independent of one another? It turns out they are not: for example if the current book does not have all the information about chapters available, then obviously the media corresponding to those chapters has not been downloaded on the device. And media can be downloaded on the device only for the case when the application runs as a native application on the device (Cordova).

How many output cases do we have? It turns out there are only 4:

  1. Book is listed with “Download to device”/”Delete from device” buttons
  2. Book is listed but without buttons (because it cannot be downloaded on the device)
  3. Instead of the book we show a “Retrieving information about this book” text
  4. Book is listed with a text on top saying: “This book cannot be played in offline mode”

FizzBuzzAudiobook

Why FizzBuzz matters? Because you will meet something similar in real life and you will have to deal with it. Only that, in real life, you may not have only 2 boolean conditions, independent of each other and conveniently having to produce 4 outputs, one for each combination. In real life you may have 4 boolean conditions with some dependencies on each other and less outputs than the number of valid combinations. But the main difference is that, in real life, you have to formulate the problem, because it is not given to you. You have to find the optimal number of outputs for your case and you have to find what variables and conditions they depend on. And for someone that does not pass the FizzBuzz test, the real-life case will be impossible to figure out.

 

  1. The audiobook mobile application I am talking about is called Digiacademy and it is currently in Beta on Google Play. If you have an interest in audiobooks, you have an Android phone or an iPhone and you want to beta-test the app, please let me know. IMG_0163
Post Tagged with , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.