2014-12-15

Deconstructing the Cake Pattern

This article provides a technical comparison between using the cake pattern and constructor injection for doing dependency injection in Scala. I show that within a small handful of refactoring steps, we can migrate from the cake pattern to constructor injection. We lose one minor feature along the way. The lost feature is not terribly desirable anyway, and can be emulated with constructor injection if need be. In exchange, we jettison the boilerplate and the opaque nature of the cake pattern.