Record of experiments, readings, links, videos and other things that I find on the long road.
Registro de experimentos, lecturas, links, vídeos y otras cosas que voy encontrando en el largo camino.
Tuesday, March 29, 2016
Monday, March 28, 2016
Interesting Talk: "Designing Front End Applications with core.async"
I've just watched this great talk by David Nolen:
Interesting Talk: "Invention, Innovation and ClojureScript"
I've just watched this wonderful talk by David Nolen:
Wednesday, March 23, 2016
Interesting Talk: "Controlling Time and Space: understanding the many formulations of FRP"
I've just watched this wonderful talk by Evan Czaplicki:
Tuesday, March 22, 2016
Interesting Talk: "Code Smells: Your Refactoring Cheat Codes"
I've just watched this great talk by John Pignata:
Here is the code of the example shown during the talk.
Kata: Open-Closed Principle in Ruby
Last week some friends from Software Craftsmanship Gran Canaria and I practiced doing Matteo Vaccari's Open-Closed Principle kata.
Jose M. Deniz Suarez and I paired to solve it using Ruby.
We got two versions of the code.
These are the tests:
and the code of the first version:
In this first version, we used a reduce over a list of translators. Each translator might add or not a translation of the given number to the resulting string.
To try something different from what we've tried other times, we used a template method pattern to remove the duplication between the tranlators.
Even though, we reduced the duplication, we didn't like the solution because the resulting Translator interface (public methods) had parameters that were not used by some of its derived classes.
Next, we deleted the code and try another approach. This time we used the decorator pattern.
The tests were the same except for the sayer factory method:
and this the resulting code:
Then we refactored it to remove some duplication and added a new translation whose condition didn't have to do with being multiple of some number.
This forcer us to generalize the translators passing them a predicate and a translation string through their constructors.
These are the resulting tests (only showing the new test and the sayer factory):
and code:
https://gist.github.com/trikitrok/619ecabe5ff9f8b08dac
It was a lot of fun.
The constrainsts of this kata are very interesting to practice refactoring and understand the OCP principle.
You can find the code in this GitHub repository.
I'd like to thank Matteo Vaccari for creating it and the great people of Software Craftsmanship Gran Canaria for the fun and the interesting discussions about the different solutions we got.
PS: The "bokata de pata" was also great :)
Jose M. Deniz Suarez and I paired to solve it using Ruby.
We got two versions of the code.
These are the tests:
and the code of the first version:
In this first version, we used a reduce over a list of translators. Each translator might add or not a translation of the given number to the resulting string.
To try something different from what we've tried other times, we used a template method pattern to remove the duplication between the tranlators.
Even though, we reduced the duplication, we didn't like the solution because the resulting Translator interface (public methods) had parameters that were not used by some of its derived classes.
Next, we deleted the code and try another approach. This time we used the decorator pattern.
The tests were the same except for the sayer factory method:
and this the resulting code:
Then we refactored it to remove some duplication and added a new translation whose condition didn't have to do with being multiple of some number.
This forcer us to generalize the translators passing them a predicate and a translation string through their constructors.
These are the resulting tests (only showing the new test and the sayer factory):
and code:
https://gist.github.com/trikitrok/619ecabe5ff9f8b08dac
It was a lot of fun.
The constrainsts of this kata are very interesting to practice refactoring and understand the OCP principle.
You can find the code in this GitHub repository.
I'd like to thank Matteo Vaccari for creating it and the great people of Software Craftsmanship Gran Canaria for the fun and the interesting discussions about the different solutions we got.
PS: The "bokata de pata" was also great :)
Thursday, March 17, 2016
Subscribe to:
Posts (Atom)