重厚長大なエンタプラーイズソフトウェア風にFizzBuzz問題を解決する「FizzBuzzEnterpriseEdition」が発表されました。
ちなみにFizz Buzz問題はプログラムの素養をテストするために使われる簡単な問題で、「順番に数字をプリントするプログラムを作りなさい。ただし、3の倍数のときは「Fizz」と、5の倍数の場合は「Buzz」と、3と5の倍数の場合には「FizzBuzz」とプリントすること」といった問題です。
開発言語は大方の予想通り(?)Java言語でした。
package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.BuzzStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.BuzzStringPrinterFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.FizzStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.FizzStringPrinterFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.IntIntegerPrinterFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.IntegerPrinterFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.IsEvenlyDivisibleStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.LoopComponentFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.NewLineStringPrinterFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.NoFizzNoBuzzStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.StringPrinterFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.loop.LoopCondition;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.loop.LoopInitializer;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.loop.LoopStep;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers.IntegerPrinter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers.StringPrinter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleStrategy;
public class FizzBuzz {
public void fizzbuzz(int n) {
LoopComponentFactory myLoopComponentFactory = new LoopComponentFactory();
LoopInitializer myLoopInitializer = myLoopComponentFactory.createLoopInitializer();
LoopCondition myLoopCondition = myLoopComponentFactory.createLoopCondition();
LoopStep myLoopStep = myLoopComponentFactory.createLoopStep();
IsEvenlyDivisibleStrategyFactory myFizzStrategyFactory = new FizzStrategyFactory();
IsEvenlyDivisibleStrategy myFizzStrategy = myFizzStrategyFactory.createIsEvenlyDivisibleStrategy();
StringPrinterFactory myFizzStringPrinterFactory = new FizzStringPrinterFactory();
StringPrinter myFizzStringPrinter = myFizzStringPrinterFactory.createStringPrinter();
IsEvenlyDivisibleStrategyFactory myBuzzStrategyFactory = new BuzzStrategyFactory();
IsEvenlyDivisibleStrategy myBuzzStrategy = myBuzzStrategyFactory.createIsEvenlyDivisibleStrategy();
StringPrinterFactory myBuzzStringPrinterFactory = new BuzzStringPrinterFactory();
StringPrinter myBuzzStringPrinter = myBuzzStringPrinterFactory.createStringPrinter();
IsEvenlyDivisibleStrategyFactory myNoFizzNoBuzzStrategyFactory = new NoFizzNoBuzzStrategyFactory();
IsEvenlyDivisibleStrategy myNoFizzNoBuzzStrategy = myNoFizzNoBuzzStrategyFactory.createIsEvenlyDivisibleStrategy();
IntegerPrinterFactory myIntIntegerPrinterFactory = new IntIntegerPrinterFactory();
IntegerPrinter myIntIntegerPrinter = myIntIntegerPrinterFactory.createPrinter();
StringPrinterFactory myNewLineStringPrinterFactory = new NewLineStringPrinterFactory();
StringPrinter myNewLinePrinter = myNewLineStringPrinterFactory.createStringPrinter();
for (int i = myLoopInitializer.getLoopInitializationPoint(); myLoopCondition.evaluateLoop(i, n); i = myLoopStep.stepLoop(i)) {
if (myFizzStrategy.isEvenlyDivisible(i)) {
myFizzStringPrinter.print();
}
if (myBuzzStrategy.isEvenlyDivisible(i)) {
myBuzzStringPrinter.print();
}
if (myNoFizzNoBuzzStrategy.isEvenlyDivisible(i)) {
myIntIntegerPrinter.printInteger(i);
}
myNewLinePrinter.print();
}
}
}
メインのFizzBuzz.javaだけでもこの冗長さはすごいですね。他にいっぱいパッケージがあります。
さすが我らがJava言語誇らしい(ジョークです。