Chris Sainty

A technical blog covering full-stack web development.

twitter | github | stackoverflow

in ,

Wrapping synchronous code in a Task returning method

Imagine you have an interface.

public interface IAsyncCommand
{
  Task ExecuteAsync();
}

Read More

in ,

Interfaces again

In my recent post about interfaces I showed one approach to breaking up and consuming your interfaces that I am finding interesting at the moment. The idea was born out placing restrictions on myself and trying to be explicit about my dependencies. I wanted to structure the code in a way where I couldn’t get lazy and just start firing off database code from anywhere in the codebase.

Read More

in , ,

Fun with Explicitly Implemented Interfaces

I’ve picked up a new coding technique recently.
I’ve always been a bit uncomfortable with the 1:1 relationship between class and interface. I’ve also been uncomfortable with large service classes like a repository.

When you take a dependency on a large service interface you are hiding all the details about what you are actually dependent on, which can cause you problems down the line with your tests and refactorings.
Repositories in particular quickly escalate to large numbers of functions. If I am working on tests for a piece of code that takes a dependency on that repository I have no option other than to read the code to see what methods it is calling. Tedious.

Read More

in

Avoid branching

One thing I have noticed recently is that I like to avoid branching. Now what I am talking about here is not branching at a code level. I am talking about mental branching as I am writing code, following other trains of thought or investigating problems whose answers are not immediately necessary.

It seems obvious, but after following along some conversations on twitter recently I think I need to post more, even for things I find obvious. So…

Read More

in , , ,

Enabling sessions in Nancy

As you may know, AppHarbify is built with Nancy. One of the reasons I decided to build it in Nancy, other than the fact that Nancy is awesome, was that I wanted to put together a real project that can be used as an example of Nancy in action. All the code for AppHarbify is available on GitHub.

To go with that I am planning to put together some blog posts talking about various aspects of the code. To start with I am looking at sessions.

Read More