Friday, January 29, 2016

Kata: Alphabet Cipher in Clojure

I just redid the Alphabet Cipher kata from the fantastic Carine Meier's Living Clojure book.

I had done it some time ago with Eloi Poch and Rafa Gómez (thanks guys I had a great time) at a Clojure Developers Barcelona event.

These are the tests using Midje:

and this is the final code:

I used a mix of TDD and REPL-driven development committing after each green and each refactoring.
What I did was tinkering in the REPL to get rough versions of encode, decode and decipher functions. This kind of tinkering is getting more and more fun, the more I get used to working in the REPL.
Once I had the rough version I just copied it directly on the code, stabilized it with some tests and started to refactor it until it seemed a bit more readable to me.

See all the commits here if you want to follow the process.

You can find all the code on GitHub.