Some time ago I implemented the GSO algorithm in C++ to practice TDD.
I decided to implement it it again in Clojure to practice with something larger that Exercism exercises or katas an yet small and familiar enough to finish it in spare bits of time.
This is the code of the resulting Clojure GSO on GitHub.
This GSO Clojure version is much shorter than its C++ version.
Aside from practicing Clojure, I've learned many other things while doing it.
I'll try to enumerate them here:
- Mixing Java and Clojure code in order to use a Sean Luke's Mersenne Twister Java implementation.
- I learned more about Midje's checkers.
- dire library.
- Decomposing a bigger Clojure application in several name spaces according to roles and responsibilities.
- Using maps to model the data.
- Struggling to make the code more readable and keeping functions at the same level of abstraction.
- Using only higher-order functions to compose the algorithm (I set myself the constraint to use no global configuration maps).
- Taking advantage of those higher-order functions to test the different parts of the algorithm in isolation.
- Separating the code that builds the graph of functions that compose the algorithm from the algorithm itself.
- Where would I apply a library like component instead of relying only n higher-order functions.
- Many other little Clojure things.
I'd like to thank Álvaro García, Natxo Cabré and Francesc Guillén from the Clojure Developers Barcelona meetup for their feedback and Brian Jiménez for rubbing elbows with me in the first C++ version.
No comments:
Post a Comment