Suri was about to add some new functionality to an existing application, and since it was a relatively big change, she spent a few hours tidying up the codebase. Sitting in there, in the code actually running in production, she found this:

/** * The VehicleConfigurationModel class. */ public class VehicleConfigurationModel { public static void main(String[] args) { for (int counter = 0; counter <= 20; counter++) { if(counter % 3 == 0){ System.out.print("Fizz"); } if (counter % 5 == 0){ System.out.print("Buzz"); } else { System.out.print(counter); } System.out.println(""); } } }

This is the entire class. Its main is never called, rendering this class a complete do-nothing class. But it's also got some of the other fun features of bad code: meaningless comments, misaligned braces, and then of course, the most important thing: it's wrong.

It's a FizzBuzz implementation, but as written, it would output the number on anything that's divisible by three and not five- 1 2 Fizz3 4….

Clearly, someone was trying to learn something by writing this code. But, as Suri points out: "Maybe something was learned, but maybe there's a few more lessons left here."

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!