Yesterday we shared with you the code kata exercise we worked on during last week’s Code Kata Night. Today, we will begin looking at some of the code our participants came up with for the Look-and-Say sequence beginning with java. Take a look to see if this is how you would have coded it…
Test-Driven Even with Throw-Away Code:
One implementation written at the code kata event was produced by Chris. Chris developed a regular expression implementation in Java that also uses recursion. When we develop throw-away code in a short amount of time, we can be tempted to not be test-driven, or to not use JUnit, but rather put all of our code in the same basic implementation class, and test it with a “main” method.
Chris’ code, however, shows us why we don’t have to write code that way in order to have everything in one convenient place. All of his code is in a test class, with an inner implementation class that contains the heart of the look-and-say sequence algorithm.
Check out Chris’ code…