All posts by Juan Lebrijo

Update your Ubuntu to Java 7

Download last release from oracle.com, I downloaded jdk-7u1-linux-x64.tar.gz.

Unzip it: tar xvf jdk-7u1-linux-x64.tar.gz

Copy to right place: sudo cp -r jdk1.7.0_01 /usr/lib/jvm

Create java7 alternative: sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_01/jre/bin/java 1

Choose the alternative: sudo update-alternatives –config java

You can choose between many jvm’s easily.

enjoy!!

Fizz Buzz Java kata

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

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,…):

Class Diagram