Saturday, October 18, 2014

Introduction to TDD with Barcelona JUG and SCBCN

Yesterday Álvaro (@alvarobiz) and I facilitated the Fractions Arithmetic kata. It was an activity organized by the Barcelona Java Users Group and the Barcelona Software Craftsmanship Community. Thanks to Ignacio Cougil and Jonathan Vila for having the idea and making this event possible.

Since the kata was meant to be an introducction to TDD, we had first a short talk explaining a bit what TDD is about.

The talk took longer than I expected because we discussed about topics, such as, TDD, object-oriented design or refactoring. Thanks for the questions and comments, I think they lead to interesting discussions.

Then we started the kata working in pairs.

In the Fractions Arithmetic kata you have to develop the arithmetic of rational numbers but, in this occasion, we limited ourselves to just developing the addition of rational numbers. We modeled the rational numbers as value objects and the fractions had to be reduced.

Álvaro and I went from pair to pair commenting with them their approaches, helping when some pair was stuck, talking about some possible refactorings, etc.

I enjoyed the experience a lot and I hope all participants took something useful home.

We talked about some books and talks that might be interesting to learn more about TDD.

These are the links:
Thanks to all for coming. We'll see each other in the next one.

Sunday, October 5, 2014

Exercism: "Atbash Cipher in Clojure"

I solved the Atbash Cipher problem in Clojure.

This is my solution:

And this is the same but using the ->> macro inside the encode function:

For this exercise I had to learn how the padding parameter of the partition function works.

You can nitpick my solution here or see all the exercises I've done so far in this repository.

Exercism: "Allergies in Clojure"

I solved the Allergies problem in Clojure.

This is my first iteration of the solution:

And this is the second one which is tail-recursive:

This problem was very interesting. To solve it you need to find a solution for a problem called subset sum. Both iterations use backtracking to find the subset of numbers that sum to the allergies score.

I had used this backtracking algorithm once before to solve the N-Queens problem in Racket for the Introduction to Systematic Program Design 1 Coursera course.

You can nitpick my solution here or see all the exercises I've done so far in this repository.

Saturday, October 4, 2014