Business-Friendly Functional Programming – Part 2: Testability

In part one of this blog series, we introduced a monadic macro from the Each library, and showed how it can simplify asynchronous operations. In part two, we will investigate how to gain testability without mocks and stubs, and still keep transparency from the business point of view.

Two years ago, Ken Scambler wrote a blog To Kill a Mockingtest,
which describes why we should use the command pattern to wipe out side effects and enhance testability. In this article, we will see how to implement the command pattern with the help of Scalaz and the Each library.
Continue reading

Business-Friendly Functional Programming – Part 1: Asynchronous Operations

Recently, we refactored one of our micro-services in order to apply the Each library. Each is a macro library developed by Thoughtworks that converts native imperative syntax to scalaz‘s monadic expressions. This means that we can write, among other things, asynchronous code with Futures in a plain imperative style.

The micro-service is a Scala application that serves as a RESTful server. It receives requests from browsers. For each of the requests, the micro-service fetches data from other internal RESTful servers, composites these data into one response, and sends the response to browsers.
Continue reading