Friday, November 24, 2017

Kata: Fractions in JavaScript ES5 using the Function as Object pattern

One of the katas I use to start practicing TDD with my mentees is the Fractions kata. This kata is great to practice writing a good list of examples and doing small baby steps. I first learn about it while doing the J. B. Rainsberger wonderful TDD course.

We usually do it in Java, but last week Antonio and I did it in JavaScript ES5 using the Function as Object pattern. This is a very interesting pattern to create objects that you can use in any language with first-class functions and closures. In Codesai we use and teach this pattern when working in projects using ES5.

We had a great time doing this kata in several short sessions that are also helping me in my recovery process.

These are the tests we wrote:

and this is the resulting code:

See all the commits here if you want to follow the process. You can find all the code on this GitHub repo.

Interesting Talk: "Cultivating Your Design Heuristics"

I've just watched this wonderful talk by Rebecca Wirfs-Brock

Friday, November 17, 2017

Native/Browser SPA versions using ClojureScript and re-frame talk at SCBCN17

Last month I had the pleasure of giving a talk at the Software Craftsmanship Barcelona 2017 conference about what my colleague Francesc and I have been learning lately while working on the mobile and browser versions of a SPA using ClojureScript and re-frame.

I talked mainly about how re-frame's effects and coeffects, re-frame's subscriptions and modelling a UI as FSMs place you in a pit of success, i. e., a design that, according to Jeff Atwood, "makes it easy to do the right things and annoying (but not impossible) to do the wrong things".

It was my first talk in a big conference and I had some technical problems, so I was very nervous at the beginning. After a while I relaxed and felt better. In the end I received more questions than I expected and very nice feedback.

I'd like to thank Modesto for lending me his computer when mine crashed just before the talk and helping me relax.

This is the video of the talk, (thanks Autentia for recording all the talks and for being so kind to me when I was having technical difficulties). I hope you'll find it interesting:

and these are the slides that I've improved after the talk using Modesto's feedback (thanks!!): .

Thanks to Francesc and all the people in Clojure Developers Barcelona Group, Green Power Monitor and Codesai that contributed to improve the talk with their feedback. Also thanks to my colleague Antonio for "persuading" me to give a talk in a conference.

Finally, I'd also like to thank Software Craftsmanship Barcelona 2017 conference organizers for giving me the opportunity to talk at such a great conference and for all the effort they put to make this conference better, edition after edition.

Wednesday, November 15, 2017

Course: Purely functional Scala

Last June I attended the amazing Habla Computing's Purely functional Scala course in Madrid.

It's a challenging course in which we learned about type classes, functors, monadic APIs and composition of effects. It's tough but very interesting, and I discovered a very flexible and robust way of designing software which goes beyond what you can achieve using ports and adapters in OO.

Habla Computing's team explains these concepts in a very creative and accessible way that gently takes you from what you already know from OO (separations of concerns, ports and adapters,...), into the monadic APIs, so that you can see the need for the new patterns and how they come to be, without losing yourself in too much mathematical jargon.

I wanted to do this course since I met Juan Manuel Serrano in the first Lambda World in Cádiz two years ago, and when I finally had the chance to attend it, I loved it. Juan Manuel is the CTO of Habla Computing and he is doing a great work in making functional programming more accessible (I've posted several of his talks in this blog). I really recommend Habla Computing's course to anyone that would like to enter the world of functional programming.

Thanks a lot to Habla Computing's team for this great course!

Monday, November 13, 2017


I've recently suffered from Miller-Fisher syndrome. In short, my immune system attacked my nervous system. The medication I received at the hospital stopped the progression of the disease. Now my body has to recover on its own. bit by bit.

It has affected my sight, arms and legs. Let's say that the latency of my nerves is a bit too high at the moment. I'm much better thanks to the medication. I can walk again, even though my equilibrium is not very good. My brain has to work extra to compensate the lack of information it receives, so walking and/or standing for a while makes me exhausted. I'm walking everyday and with physiotherapy sessions this will improve soon. What will take longer is recovering my sight because the nerves that control eye movement are more precise. I was told it'll take between 4 and 6 months to see well again. At the moment I see double and a bit fuzzy.

To avoid seeing double I'm using eyepatches that I alternate so I use each eye half of the day. I'm starting to read, write and/or draw 20' with each eye everyday to practice. It's also a bit tiring but I'm improving day by day.

If everything goes well with the physiotherapy sessions, I hope to be able to work 4 hours a day by January. Let's see.

I'd like to thank my family for their support, especially María, who was by my side through the worst of it, and my parents, who have moved to Barcelona to live with us while I recover. I'd also like to thank all my friends and colleagues for visiting me and for their messages of support. Finally, I'd like to thank the professionals of the CAP Les Corts and the Hospital Clínic for healing and taking care of me so well. We really appreciate it. I'm very happy and proud that we have a public health system in our country. Let's protect it.