Fizz Buzz Java kata
Nov 01, 11 by Juan Lebrijo about blog, agilism, Eclipse, Java
At XPWeek2011 we learned TDD coding, and the importance of OOP principles to develop applications. I spent great days there, thanks to Carlos Ble and iExpertos. Continuing with the last kata series. I will show you how I solved FizzBuzz kata, maybe not the best, but I like the solution because the expressive final code:
  • say(FIZZ, WHEN_FIZZ_FACTOR);
  • say(BUZZ, WHEN_BUZZ_FACTOR);
  • elseSayNumber();
Here you have KataFizzBuzz Here you have the code: fizzbuzz.zip And here you have the video:
Roman Numerals Java kata
Oct 16, 11 by Juan Lebrijo about UML, methodologies, blog, Java
Siguiendo con la serie de katas, ahora toca la kata de los números romanos. Es simple, se trata de convertir de entero a romano y viceversa. Para darle una vuelta de tuerca me he propuesto seguir los principios KISS y SOLID, que se recomienda tener en mente cuando refactoricemos. Y ya de paso me he propuesto implementar una Interfaz fluida basada en métodos estáticos:
  • convert(roman).toArabic();
  • convert(arabic).toRoman();
El video de la kata lo teneis en Youtube: El código de la kata aquí: romannumerals-fluentinterface-solid.zip Y por último un diagrama de clases que ilustra como el diseño respeta el diseño Open/Close, en tanto en cuanto fácilmente, añadiendo más subclases, podremos ampliar a tantos sistemas numéricos como queramos (Octal, Hexadecimal,...):
model.png 10.5 KB
Roman Numerals Java kata
Oct 16, 11 by Juan Lebrijo about UML, methodologies, blog, Java
Continuing with kata series, here we have roman numeral kata. Simple, you have to convert roman to integer and integer to rman. In order to improve other things I purpossed to follow KISS and SOLID principles. Also creating a Fluent Interface based on static methods:
  • convert(roman).toArabic();
  • convert(arabic).toRoman();
The movie on Youtube: Kata code here: romannumerals-fluentinterface-solid.zip Finally, a class diagram illustrating the Open/Close principle which I tried to follow, here we can add more numeric systems only by adding the corresponding Number subclasses (Octal, Hexadecimal,...):
model.png 10.5 KB