Last week, we had our first taste of Exercises in Programming Style. Remember, the goal is to write a simple program, but to comply with some constraints. The previous constraint was that there was only a single variable available, an array. With a statically-typed language such as Kotlin, it required a lot of casting variables to their correct types before using them. This week, the constraint is as radical, but different. Instead of a single array, we have two data structures available: a hash
Recently, my colleague Bertrand lent me a copy of the book Exercises in Programming Style by Cristina Videira Lopes. Among all the books that sit on my reading pile, I decided to put it on top, and started reading right away. Currently reading Exercises in Programming Style by @cristalopes - and doing the exercices in #Kotlin. IMHO, it's one of the best (if not the best) book on programming I've read so far! I'll probably blog about it.Thanks @bertrand_cachet for the pointer—
I manage my Jekyll blog in a Git repo. My publication process uses 2 branches: master contains all production content, and feature/newposts has the new blog posts, ready to get published, one commit per post. To publish an existing post: I check the to-be-published post in the `feature/newposts` branch. Then, get the associated commit. And cherry pick it in the master branch. Finally, I push.
I started working with Git some years ago, and to be honest, it was not easy to pick up. It's a huge beast, and there are several ways that can help to tame it. On the web, most articles focus on creating command shortcuts. In general, this goes like: instead of writing git pull --rebase, let's create a shortcut to type gpr.
This is the 4th post in a series about migrating to functional programming. This week, I'll first implement the Dijkstra algorithm, then migrate the code to a more functional-friendly design. Dijkstra's algorithm allows to find the shortest path in any graph, weighted or not, directed or not. The only requirement is that weights must be positive.
Since already some years, this site uses the Jekyll static site generator. Generating the complete site takes about 15 minutes. Some time ago, I decided to setup Gulp to minimize HTML in order to speed up page view for readers. This change added about 10 minutes to the build time, for a total of ~25 minutes, which is a long time… too long. I wanted to decrease the build time, so I decided to play around. The initial state A Docker image is used to build the site. The image is bas
I was not a fan of assertions libraries at first. Whether assertions provided by the testing frameworks were enough is debatable. But those libraries provides the way to write custom assertions closer to the business language. While the intention is commendable, I always thought this path was a slippery slope. If one starts writing such custom assertions, then they need to be tested obviously. And then, when will it stop? However, there’s no denying assertion libraries make writing assert
It might happen that you need to deduplicate a list of items… coming from legacy code. The class - let’s call it LegacyObject has already implementations for equals() and hashCode(). It’s not possible to change the implementation, for fear of breaking the running code. And unfortunately, the Java API doesn’t offer a distinctBy() feature. In that case, a cheap trick is to create a wrapper class around LegacyObject, with the desired implementation: public class L
A derived attribute is an attribute computed from other attributes e.g.: The fullName is aggregated from the first, middle and last nameThe age is computed from the birthdateetc. Kotlin offers different options to manage such derived attributes. Let’s browse through them. Inline field initialization The simplest way to manage derived attributes is to declare a property, and compound its declaration with its initialization: class Person(val firstName: String, val middle