02 Jul 2016 Comment

These days, my default approach for writing tests is to construct the system under test using the builder pattern. Delegating construction of the SUT to a fluent builder has a number of benefits:

  1. Test code becomes more readable and expressive, encouraging meaningful tests, preventing setup code from drowning out test intention and ultimately providing better documentation of behaviour.
  2. Reuse of setup code is easier and the cost of adding or changing dependencies and construction logic is dramatically reduced.
  3. Semantically meaningful test setup encourages good encapsulation in production code (which, in turn, makes changing behaviour by adding and removing components - instead of ripping up tests - much easier).
  4. Dependencies’ validity can be tested in a single test and “assumed” in others by supplying valid defaults in the builder, further reducing noise in tests.

Continue reading...

09 Mar 2016 Comment

Done right, feature toggles are a powerful way of postponing the activation of features in a continuous delivery workflow.

Done wrong, though, they can be a burden, bringing unnecessary complexity, obscuring broken code and becoming difficult to remove when the time comes.

The difference between whether feature toggles are a help or a hindrance hinges on two key things: when you apply them and where in your codebase they’re managed.

Continue reading...

03 May 2015 Comment

There’s a little motif that I’ve seen dotted around async C# code. It seems to surface when developers find themselves needing to consume an asynchronous API without yet having fully grasped how async works.

The specifics differ, but the gist is always the same. There’s a service layer, which makes an async call to a third party with ConfigureAwait(false) :

Continue reading...

12 Oct 2014 Comment

I’ve recently started working with CouchDB and am finding it to be a really elegant way of storing and retrieving data. In my adventures around the Internet in search of related resources, I have found that - in spite of the maturity of CouchDB and similar document databases - there still seems to be a lot of confusion about reduce functions and, in particular, their mysterious rereduce parameter.

The documentation around reduce functions can be a bit obscure so, in this post, I’m going to talk through the process of building a CouchDB reduce function from the ground up. I’ll build a simple view to report on the numbers of books in a multilingual “digital library” application and then discuss the mysterious rereduce parameter, what it is and its importance.

Continue reading...