Category Archives: Scala

Scala TDD

String Calculator for Scala

This is a slight repurposing of the String Calculator kata on Roy Osherove’s website. I’ve updated it for my own impression of TDD, and for Scala notation and types, but many of the words are still arranged in Roy’s order. read more »

Play Framework Scala

Keep controllers clean with custom action builders

When writing controllers, there are often elements that are needed over and over again. Maybe you always seem to be getting the same objects from a repository, or you want to do authentication. Repeating simple operations like these leave controller actions bloated, and hard to read. Play Framework offers a simple and powerful way to abstract these repeated elements.

read more »

Scala

Play DI: compile time versus runtime

Scala’s Play Framework provides a runtime dependency injection mechanism by default, courtesy of Google Guice. The framework is built with flexibility in mind however, and so allows developers to replace the default application loader with a custom one that allows dependencies to be resolved at compile time. More details on this technique can be found here.

For the last couple of weeks, basically since reading Loïc’s blog post, I’d been working under the impression that compile time DI is a safer, and therefore better, approach. Having just spent a rather unhappy day trying to functionally test non-trivial implementations, I’m no longer convinced. In this post, I’m going to put forward my arguments for both cases in the hope that it will help me make up my mind.

read more »