This post has been updated Click here In this post I will outline an updated perspective on Commands and Queries. If you are unfamiliar with these two patterns then please see these posts here and here for a great introduction. For the remainder of this post I will assume you have fully subscribed to the idea of parameter objects and… Read more →
Category: C#
Method Injection with Simple Injector
In this post I will outline a trick I created while experimenting with the code for my post Managing Commands and Queries. If you are unfamiliar with these two patterns then please see these posts here and here for a great introduction. For the remainder of this post I will assume you have fully subscribed to the idea of parameter… Read more →
Managing Command and Query Parameter Objects
In this post I will outline some of the techniques I employ to manage my Commands and Queries. If you are unfamiliar with these two patterns then please see these posts here and here for a great introduction. For the remainder of this post I will assume you have fully subscribed to the idea of parameter objects and are comfortable… Read more →
Patterns & Abstractions
Patterns and Abstractions My central architectural pattern of choice is CQRS. Commands Actions that change something and return nothing public interface ICommandHandler<TCommand> where TCommand : ICommand { void Run(TCommand command); } Queries Actions that return something and change nothing public interface IQuery<TResult> { } public interface IQueryHandler<TQuery, TResult> where TQuery : IQuery<TResult> { TResult Execute(TQuery query); } Mediators A combination… Read more →
Debug IIS/global.asax within Visual Studio
Taken from this SO answer You may create a post-build event which changes the timestamp of a web.config file. I used a touch.exe tool from http://www.stevemiller.net/apps/. You also need to set the “Run the post-build event” to Always. With this option set anytime you start the debugger, web.config timestamp is getting updated causing application (thus IIS pool) restart on the… Read more →
Referencing the container is not automatically the Service Locator Anti-pattern
This post will briefly describe when it is ok to reference a container in your application. What is a Container? A container is an object that you delegate the responsibility of creating and managing your object graphs and object lifetimes. What is a Service? A Service is an object that exposes one or more methods. What is the Service Locator… Read more →
Elmah in the Enterprise: a 3 tier solution
Elmah is a fantastic error logging solution for ASP.NET, but it has one “feature” that can prevent its adoption in the enterprise – errors can be stored on the local drive or to a database, neither of which are working for my employer. Error details should not be stored on the web server and the web server cannot be given… Read more →
Building a Func<TEntity, bool> delegate from an anonymous object
The background to this code is that I’m getting rid of Entity Framework – it’s too slow and IQueryable is so cool but ends up sucking by slowly bleeding into the code base and thereby becoming difficult to performance tune. Thanks, as always, go to my friend .NETJunkie for his remarkable post on the query pattern that has led me… Read more →
Migrating from NUnit to xUnit
These regular expression came in handy recently – they’re not perfect, in particular a couple of the second grouping need to be more greedy – but I did the migration first time through so didn’t get to improve them. Find: Assert.That((.+?), Is.EqualTo((.+?))) Replace: Assert.Equal($2, $1) Find: Assert.That((.+?) == (.+?)) Replace: Assert.Equal($2, $1) Find: Assert.That((.+?), Is.StringContaining((.+))) Replace: Assert.Contains($2, $1) Find: Assert.That((.+?).Contains((.+)))… Read more →
Microsoft’s Task Parallel Library and the principle behind node.js
I wanted to see how Microsoft’s Task Parallel Library compared with node.js in so far as passing the next method in to the current to chain the calls indefinitely. So I created a method that iteratively adds itself to the current executing Task. The initial test was to see if the code would fail with a StackOverflowException but what I… Read more →