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

Feeling Validated – A different way to validate your input

TL;DR

The following post is a Scala example of validating input into your software.  We use Scala, but you can do this in many other languages like Ruby, JavaScript and even Java!  After trying a more traditional approach we then use a type called Validation to encode our business rules.  It’s a different way of thinking.  It uses the Scalaz library.

Continue reading