February 1, 2010 0

String Calculator – Groovy

By Corey Haines in Katas, Uncategorized
After being away for a couple weeks due to conferences and sickness, we present another entry in our “Same Kata, Different Languages” series: the String Calculator in Groovy by Itay Maman. This will most likely be the last of the String Calculator katas for a while, as we’ve been doing them for a long time now; time for something different next week.

After being away for a couple weeks due to conferences and sickness, we present another entry in our “Same Kata, Different Languages” series: the String Calculator in Groovy by Itay Maman. This will most likely be the last of the String Calculator katas for a while, as we’ve been doing them for a long time now; time for something different next week.

Itay Maman is a hopeless programmer living in Haifa (Israel). His doing a Ph.D. was just an excuse for writing cool software and for being able to read and hack cool code that others have written (Compilers and such).
Groovy is an interesting language, since it looks so remarkable similar to Java, but definitely has less of the syntax. Here’s Itay’s description of doing the kata:
I repeatedly practiced this Kata over the last few weeks. I eventually got to the point where I felt I’m doing it on “Auto pilot”. The Kata that I recorded was a bit different – I decided to take steps that are slightly than my usual, which made the whole thing interesting as I had to improvise here and there.
The nice thing about this Kata is its diversity. In “TDD By Example” Kent Beck lists three basic “moves”: (1) Fake it till you make it; (2) Triangulation; and (3) Obvious implementation. All three moves can be found here.
“Fake it” is my default. This quickly gets me to Green thereby providing the opportunity to refactor even before the implementation is complete. I like to think about it as a preemptive refactoring. You can see it in the last test. At 10:10 I inject a fake implementation. Then I do a preemptive refactoring: I introduce the “negs” variable which is the vehicle on which the real implementation is built.
Triangulation. 4:57 minutes into the Kata I am in a position where I reworked a “Fake it” implementation into a more general form, but I am not done. There is still a hard coded assignment: “delimiter = ‘;’”. At that point I felt that I covered enough grounds in the application code so I go back to the unit test and introduce a fresh test that fails (5:07). This leaves me with no option but to generalize the assignment into “delimiter = s.charAt(2).toString()”
Obvious implementation. There are three tests where the solution is just a few keystrokes away so I directly code it in. For example, when the shouldAllowNewlines() tests yields Red (3:38) I move to the application code, add a “|\\n” to the regular expression and get back to Green in 6 seconds.
I like his description of some different techniques with TDD. I really enjoyed this katacast, as it is a pretty nice, fluid example of what you can do when you’ve practiced.
If you’d like to contact Itay:
As always, feel free to comment. Constructive comments are always welcome! If you are inspired to do your own kata and would like to prepare something for katacasts, definitely contact me.

StringCalculator Groovy from Itay Maman on Vimeo.

January 7, 2010 5

Prime Factors Kata (Annotated)

By unclebob in Katas

Uncle Bob walks and talks his way through the Prime Factors Kata.
No music, but lots of commentary.

January 6, 2010 12

String Calculator – Python

By Corey Haines in Katas, Software Craftsmanship

Continuing our series of ‘Same Kata, Different Languages,’ we have a very special performance in Python by Gary Bernhardt:
Gary Bernhardt is an independent software contractor in Seattle specializing in the dynamic languages Python and Ruby. A brutal minimalist, he is bent on the destruction of all existing software except Emacs and Vim, the two One True Editors.
Gary’s a [...]

December 30, 2009 5

String Calculator – Scheme

By Enrique Comba Riepenhausen in Katas, Software Craftsmanship

Next in the series ’same Kata, different language’ I wanted to post my very own Kata in Scheme.
Currently I am learning Scheme. Due to my lack of knowledge in Scheme I could not write the tests (nor code) for the negative numbers part of the string calculator. I would have loved to get there, but [...]

December 27, 2009 0

My Response to Roy Osherove’s Feedback on my String Calculator Kata

By Corey Haines in Feedback

Since the String Calculator kata was posed by Roy Osherove, I asked him to take a look at my solution and give me feedback. He was kind enough to write an insightful blog post with some comments. Since he took the time to write them, I thought it fair to weigh in with my responses.
Roy:
Partial [...]

December 24, 2009 3

String Calculator – Scala

By Corey Haines in Katas

Continuing our series of ’same kata, different languages,’ Giordano Scalzo provides us with a great view of the kata in Scala. I’ve fooled around a little bit with Scala, but definitely felt like I was just writing java in a not-quite-different environment. Watching Giordano code was very refreshing.
Giordano Scalzo is a Software “jack of all [...]

December 17, 2009 9

String Calculator – Erlang

By Corey Haines in Katas

For our first in the series of ’same kata, multiple languages,’ we have a treat for everyone, Gabriele Lana is doing it in Erlang.
Gabriele Lana is a software journeyman living in Milan (Italy). Since 1998 he works as a developer and consultant. In 2000 he started using Agile practices in real time and embedded industries, proving their effectiveness [...]

December 17, 2009 0

String Calculator Series – Multiple Languages

By Corey Haines in Uncategorized

For the next few weeks, we will be experimenting a bit by having guests doing the String Calculator kata in different languages. I did it originally in Ruby, and we have Erlang, Scala, Clojure and Python coming. I’ll be contacting Roy Osherove, who sparked this kata, to do it in C# for us.
Watching the same [...]

December 10, 2009 0

No Katacast this week

By Corey Haines in Uncategorized

Due to time constraints, we won’t be having a katacast this week. It takes a long time to prepare one of these, and, unfortunately, the past couple weeks have seen some unfortunate things come up to take attention. As a result, developing, practicing and screencasting a new kata each week is undoable in the short [...]

December 3, 2009 7

String Calculator

By Corey Haines in Katas

Roy Osherove and Gil Zilberfeld of TypeMock talked about the katacast series on their podcast, ‘This Week in Testing,’ and called me out to do Roy’s standard TDD practice, String Calculator. There are a few screencasts of this kata in C# linked from his page, which are well-worth watching. It is always interesting seeing the [...]