Those of you who have been keeping up with the programming blogosphere have probably heard of FizzBuzz by now. Well, in the spirit of this, I decided to create my own overly complicated FizzBuzz: FizzBuzz, Enterprise Edition.
As we all know, Java is the best language for writing enterprise applications, so that’s what I went with. Here’s a quick overview of the code:
- The FizzBuzz class is where most work is done. This class is a Singleton since we only create one instance of it.
- The doFizzBuzzApplication() method generates a list of Number objects by reading a file containing all the numbers from 1 to 100.
- It then creates a new instance of the FizzBuzzOutputManager class, sending it the list of Numbers to be printed.
- The doOutput() method of the FizzBuzzOutputManager class goes through the Number list, checking if the current object is an instance of numberDivisibleByThree, numberDivisibleByFive, etc. It then prints out the appropriate message on the screen.
- Like all good enterprise applications, there’s a lot of code in there from past versions that does absolutely nothing. The program also generates a few worthless files when it runs.
You can download the source here.
This shouldn’t be too hard to out-enterprise (especially if you throw in some SOAP web services…). If anyone else has an unnecessarily complicated FizzBuzz, I’d love to see it.