Currently browsing

October 2014

Stairs, Cakes and Injections

Dependency Injection is a design pattern meant to increase decoupling, readability and testability by wiring together component implementations so that: All their dependencies on other components’ contracts are satisfied The wiring logic doesn’t belong to any component being wired but to injectors instead Injectors can evaluate wiring rules at runtime Multiple, different injectors can coexist in a single execution Scala supports typesafe Dependency Injection and there are even several ways to implement it. Possibly the most popular one is based on the cake-pattern, which leverages Scala’s self type annotations; yet again I couldn’t find an explanation of it that was crystal clear to me, so I decided to build my own. There are four distinct conceptual layers to this Scala DI implementation strategy …

Monads for Software Engineers

The term monad could sound weird to a software engineer because it comes from category theory. There’s plenty of related maths material around but let’s just forget about it and about the choice of that word (BTW am I the only one being triggered Leibniz memories from high-school philosophy classes?): I’m interested in a software engineering perspective on the topic and, since I couldn’t find an introductory one that was clear enough for me, I decided to take a dive in and build my own. What is a monad? Very, very shortly: a data structure implements a monad interface iff it defines some “lifted-up” functions sequencing operator (think of a functional “;“-like sequencing). So a monad itself is basically …