Testing has traditionally been the gateway process for Scala development at a number of Java shops looking to evolve their tech stack with minimal disruption or committment. This posts hopes to cover three of the main testing frameworks in the Scala landscape, (Specs2, Scalatest and Scalacheck) with an example of the classic FizzBuzz test, for how they can be used for fun and profit.

I go to a fair few (probably too many), tech conference and meetups. A passing observation, is that if code samples are shown a proportion of the audience will try to run them while following along. Initially, this seems counter intuitive (to try and both listen and absorbing information while also trying to perform actions as a background task), though my own experience is that this works suprisingly well for practical activities, (maybe the multi-sensory exposure helps learning and retention ?).
Read the rest of this entry »

With every new year comes a sense of reflection and soothsaying for the year ahead.

I’ll dispense with too much commentary on the past, suffice to say it was a period fraught with duck aligning and preparing foundations to enable more interesting technical possibilities this year.
Given the need to furrow a number of disparate technology channels as part of my day job, has meant a number of personal technology areas of interest have had to be suspended for a time, but hopefully 2012 should renew my vigour and possibilites to return back to the breach.

So, from the last years experience, here’s my thoughts on what looms in 2012, driven by either interest or more likely necessity. I don’t assume these will be general trends, but if past experience is any indicator, my direction tends to reflect that in the general [web] technology landscape.
Read the rest of this entry »

This is a post I’d been meaning to submit for some time and is the chaser sibling to the SOAP fuelled scrub up, showing how to create a very simple service in the Restful style using only Java 6 and the Scala language (note I personally use Scala v2.9). Read the rest of this entry »

This post was prompted by a conversation with a good friend, who is an experienced Java developer taking their first, tentative, steps towards becoming a Scala programmer. Basically, the conversation went as follows:

“…Immutability seems good and like a goal I should aim for. How can I get this in my domain objects without having to provide a multiplicity of constructors to do partial updates ? Is it really that big a deal ? I’ve rarely had to worry about this stuff in Java at all !”

Both fair question, which I’ll try to address in the remainder of this post. Read the rest of this entry »

After many years of Java development, discovering Scala’s type system and related features was something of a departure for me. Suffice to say GADT wasn’t my first four letter utterance when learning about pattern matching on types, let alone what, when and how to use variance annotations and generalized type constraints. To kick things off, here’s a ‘small but powerful‘ few lines of buzzword bingo on the type system:

…Scala is a statically, strongly, typed language, with implicit type inference and support for structural and existential types. It also features parameterized types, abstract and phantom types and is capable of implicitly converting between datatypes. These core capabilities are utilized by context and view bounds and complimented by generalized type constraints, to provide powerful compile time contracts. Furthermore, Scala supports declaration site type annotations to facilitate invariant, covariant and contravariant type variance…

In a word, Ouch !

In the remainder of this post, I’ll try to demystify these concepts and sew the seeds of intrigue for further investigation.
Read the rest of this entry »

As the name suggests, pattern matching enables the checking of a sequence of tokens for the presence of the same pattern. Beyond the Scala language, pattern matching is a commonly employed programming technique in a number of (predominantly functional), programming languages including Haskell, Erlang, ML, Clojure and Prolog. In this post I’ll cover the different flavours of pattern matching in Scala, as well as providing reference to typesafe null and extractor patterns to cover the idiomatic usage of pattern matching in Scala.

Something I had been meaning to post for a while, was a simple snippet showing the use functions as values and/or variables in Scala and how expressive this is at conveying intent within the code. Read the rest of this entry »

So ramping up with the Scala 101 series, I thought now is an appropriate juncture to introduce control structures in Scala. To a certain extent, working with the Scala language presents a vista wherein the developer is afforded much greater freedom than in many other environments, but therein lies a great many choices and a sense of responsibility. As such, I’ve consciously tried to restrict this post to covering some of the main flavours and options for control-flow and ¬†iteration within Scala, how they differ and provide examples of usage. Read the rest of this entry »
I’ve recently had the fortune to inherit the Promethean task of evaluating a number of vendor systems, whose main interface to existing ‘enterprise‘ software/systems is via a SOAP Web Service gateway. As intriguing as this may sound, I’ve found the snippet of code below to be an incredibly useful starting point when trying to rapidly knock up a sample integration endpoint. Read the rest of this entry »