Lightweight callsite caching with F# and C#


What is Memoization? Just a simple demo outlining how you might write a simple generic callsite cache in F# aka Memoize. This is something that you can find elsewhere on the web - it's easy to write one. What I really want to illustrate is if you were to write something similar in C# how … Continue reading Lightweight callsite caching with F# and C#

Pigs in Lipstick


A "fluffy" post today, that doesn't talk about F# or EF or RavenDB etc. but about general development processes. Something I think all developers need to learn, and are always honing, is the ability to trust their instinct when something feels wrong. What do I mean by this? Well, primarily this is about identifying when … Continue reading Pigs in Lipstick

Modelling problem domains in C# and F# – Part 2


In my last post, I illustrated how we could model a simple real-world problem using classic OO concepts such as type hierarchies, interfaces and stateful objects. In this post I want to contrast that with a functional-first approach using F#. Discriminated Unions In order to model the different types of Positions on a Monopoly board … Continue reading Modelling problem domains in C# and F# – Part 2

Modelling problem domains in C# and F# – Part 1


I’m trying more and more to use F# for hobby projects etc. and finding, as usual, that there are very elegant, lightweight solutions to abstractions. This time: Monopoly. Defining a Problem Space A while ago I did something fairly simple in C# to simulate the Monopoly board that rolls two dice, moves a player on … Continue reading Modelling problem domains in C# and F# – Part 1

Why Entity Framework renders the Repository pattern obsolete?


A post here on a pattern I thought was obsolete yet I still see cropping up in projects using EF time and time again... What is a Repository? The repository pattern – to me – is just a form of data access gateway. We used it to provide both a form of abstraction above the … Continue reading Why Entity Framework renders the Repository pattern obsolete?

Using Unity Call Handlers to compose logic


The most common use of Unity Call Handlers (or Interceptors) is for cross-cutting concerns. I’ve demonstrated the use of such handlers in the past for things such as logging or caching. However, there’s another use for these handlers that allows us to build reusable blocks of business-related code that can be composed together to act … Continue reading Using Unity Call Handlers to compose logic

Why I Hate the Template Pattern – Part 2


In my last post, I discussed in detail why exactly I don’t recommend the use of the Template for writing testable code. Here I want to illustrate an alternative to it, but before I do that, I want to talk about a more fundamental aspect of OO design. Inheritance vs Composition The way I see … Continue reading Why I Hate the Template Pattern – Part 2

Why I Hate the Template Pattern – Part 1


We’ve all been there and done it – written some code that at the time seemed great but you look back on it and think “why!”. I’m hoping to save you from at least one of those situations today with a brutal dissection of the Template pattern. Seductively, it offers you a quick and easy … Continue reading Why I Hate the Template Pattern – Part 1

Generic type factories


Happy new year to everyone! I’ve really got the blog bug over this Christmas period… today, I want to talk a little about how to create easily-consumable generic classes. Generic Types and Composition Generics in C# are great. They give so many elegant ways to solve common problems and to implement certain design patterns that … Continue reading Generic type factories

Getting creative with IDisposable Part 2


In my last post, I gave some examples of how we can use the IDisposable interface in conjunction with the using statement to implement an on/off pattern wrapping around some critical region of code, even though there is no “disposable resource” involved. Problems with using IDisposable In this post I want to expand on the … Continue reading Getting creative with IDisposable Part 2