Sunday, 26 October 2014

Kata 1 - FizzBuzz in Java ( step by step)


It has been a long time since the last time I wrote here. This time I'm going to write about a completely different thing.

One week ago I started reading about Katas and TDD. Since then I have been doing two Katas every day. With this I am improving my Java skills and learning how to use TDD.

TDD (Test-driven development) is a software development process  that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.

KATA  is an exercise in programming which helps a programmer hone their skills through practice and repetition.

In this article I will do FizzBuzz Kata step by step. This is one of the easiest Katas.

FizzBuzz Kata has 4 easy rules :


  1. If the number is divisible by 3 should return "Fizz" .
  2. If the number is divisible by 5 should return "Buzz" .
  3. If the number is divisible by 15 should return "FizzBuzz" .
  4. If the number is not divisible by 3, 5 or 15 should return that number as String.

First of all you need an IDE with some unitary testing plugin. I am going to use eclipse with Junit because is the one that comes with it. You can do  Katas with the IDE you want, the unitary testing plugin you want and the programming language you prefer.

When you have your IDE ready, you have to create two classes, one FizzBuzzTest.java and FizzBuzz.java and put them in the same package.

Video step by step :



In the next video I will try to explain what I am doing, this is a first try.

For any question leave a comment.



No comments:

Post a Comment