Scala has nice abstractions for asynchronous code. However, writing tests for that code sometimes results in an ugly, unreadable mess. Fortunately, ScalaTest has built-in support for testing Futures, in addition to utilities for other types of asynchronous testing, such as polling and test-probes.
'Agile' may now be an overloaded term abused by all kinds of people, but the original manifesto is actually still quite relevant. The second point is:
Working software over comprehensive documentation
This is useful to embrace in many circumstances, and can be expanded to:
You should intially favour building software over documenting it. Comprehensive documentation can come later.
As the end of the year approaches, Twitter has a hash-tag named #Code2014 that encourages people to tweet which programming languages they've been using over the last 12 months.
In abstract algebra, a branch of mathematics, a monoid is an algebraic structure with a single associative binary operation and an identity element. Monoids are studied in semigroup theory as they are semigroups with identity.
Wikipedia has the above definition of a Monoid. This blog post will desconstruct that definition to simply describe what a monoid is, and why you would want to use one.
Aggregation services (sometimes known as Composite or Hydration services) are useful when working in SOA. In SOA, services are responsible for discrete objects and collections, yet still often need to reference other object or collections controlled by another service. This is done via referencing Ids. In order to display something useful to the user it is necessary to lookup data from multiple sources and aggregate them together.
Working out the Fibonacci numbers are a standard exercise when learning a programming language, or just refreshing your knowledge. This is a recap of various ways to calculate them in Scala. All the code is available in a handy gist.
I've been using Akka Camel and ActiveMQ recently, as part of a delayed worker-queue system. Given the lack of good googleable information about combining the two, I thought it would be useful if I explained briefly how to get Akka Camel and ActiveMQ to work together in the form of a quick example.
Using a DSL to write a test can prove to be useful, especially when there are lots of prerequisites, or the problem is complex. Having a test that is incredibly readable reduces complexity overhead and aids reader comprehension. Any tests that require the reader to retain a mental map could benefit from a DSL.
Scala has three different frameworks for writing unit tests, JUnit, Specs2 and ScalaTest. I have mainly been using ScalaTest since I started to learn Scala about four months ago. One of the areas I have been concentrating on is how to write good assertions. Specifically, ones that yield easily diagnosable error messages when they fail.