Recent Posts

Incremental Refactoring for the Win

We’ve all encountered those sprawling, unruly code bases that have grown unchecked over the years. We label them as “legacy,” but that is often just code for “code that works, pays the bills, and our customers rely on to continue working”. The challenge then becomes how to improve these code bases without causing more harm than good. In this article, we’ll explore a pragmatic approach to rejuv...

We’ve all encountered those sprawling, unruly code bases that have grown unchecked over the years. We label them as “legacy,” but that is often just code for “code that works, pays the bills, and our customers rely on to continue working”. The challenge then becomes how to improve these code base...

Tips for building effective teams

Tips for building effective teams 1 Trust your team You do not know everything. Your team may want to use a new technology or approach to solve a problem, give them the freedom to try new things but be prepared to call time on it and steer them back on to a good path if it isn’t working out. 2 Ensure your team can trust you Do not promise anything to your team unless you a) intend to follow...

Tips for building effective teams 1 Trust your team You do not know everything. Your team may want to use a new technology or approach to solve a problem, give them the freedom to try new things but be prepared to call time on it and steer them back on to a good path if it isn’t working out. 2...

Measure everything - Empty collections

What’s the quickest way to get an empty IEnumerable<string>, List<string>, or string[]? Let’s measure it. The Test As usual, code is running in a Linqpad script and is using Benchmark.Net. #LINQPad optimize+ // Enable compiler optimizations void Main() { Util.AutoScrollResults = true; BenchmarkRunner.Run<EmptyCollectionsBenchmark>(); } [Short...

What’s the quickest way to get an empty IEnumerable<string>, List<string>, or string[]? Let’s measure it. The Test As usual, code is running in a Linqpad script and is using Benchmark.Net. #LINQPad optimize+ // Enable compiler optimizations void Main() { Util....

Customising JSON serialization with Json.Net

While integrating with the API of a popular tropical-sounding online shop, I hit a problem where their Sandbox API was rejecting a perfectly valid request that the main API would most likely be fine with. In this case, it was objecting to decimals being rendered as 10.0 instead of 10, likely because the sandbox is auto-generated from the Swagger models and was just doing a string comparison on...

While integrating with the API of a popular tropical-sounding online shop, I hit a problem where their Sandbox API was rejecting a perfectly valid request that the main API would most likely be fine with. In this case, it was objecting to decimals being rendered as 10.0 instead of 10, likely bec...

Measure everything - Count() vs Any()

Within any community, there are often a series of untested truths. Within development communities, this often takes the form of X is faster than Y or Z is more efficient than W. While these are often true at some point, we don’t often test them to see if they remain true years later. One such instance is Count() vs Any() on IEnumerables and Collections. The general wisdom as I understand it is...

Within any community, there are often a series of untested truths. Within development communities, this often takes the form of X is faster than Y or Z is more efficient than W. While these are often true at some point, we don’t often test them to see if they remain true years later. One such in...

My approach to improving a messy codebase.

In the just over a decade I have been a professional developer, I’ve had to work with alot of messy code, only some of which I wrote. As a result, I’ve spent alot of time refactoring messy code to try and make it in to something better and want to share some of my methods for achieving this. How I approach this has changed over the years but the below are areas I try to focus on and why. The o...

In the just over a decade I have been a professional developer, I’ve had to work with alot of messy code, only some of which I wrote. As a result, I’ve spent alot of time refactoring messy code to try and make it in to something better and want to share some of my methods for achieving this. How...

Handling rate limiting with RestSharp and Polly

I was recently working on an integration with an API that has Rate-Limiting, that is if you go over the permitted number of requests within a certain period of time, you’ll receive a 429 response along with a header telling you how long you need to wait before trying again. I’ve been watching Polly for years but haven’t had the chance to use it, so this seemed like the perfect opportunity and ...

I was recently working on an integration with an API that has Rate-Limiting, that is if you go over the permitted number of requests within a certain period of time, you’ll receive a 429 response along with a header telling you how long you need to wait before trying again. I’ve been watching Po...

Bicep - Create Azure Service Bus with topic and filtered subscription.

It’s been a while since I’ve done anything with Service Bus so to get myself back in to it and indulge my current enjoyment of Bicep, I thought i’d start with creating the service bus, along with a topic, and a filtered subscription, all in Bicep. To start with, the main.bicep which is virtually the same as last time you saw it: param appname string = 'testapp' param environment strin...

It’s been a while since I’ve done anything with Service Bus so to get myself back in to it and indulge my current enjoyment of Bicep, I thought i’d start with creating the service bus, along with a topic, and a filtered subscription, all in Bicep. To start with, the main.bicep which is virtually...

Dependency substitution for legacy code

This post shows an example of how to introduced a form of dependency injection in to legacy code with minimal changes. I refer to this as dependency substitution because, in my view at least, there is a subtle difference between this and depdendency injection. With dependency injection, we are injecting the dependency via either constructor or property injection. The dependency is set once by ...

This post shows an example of how to introduced a form of dependency injection in to legacy code with minimal changes. I refer to this as dependency substitution because, in my view at least, there is a subtle difference between this and depdendency injection. With dependency injection, we are i...

Copying messages between SQS queues

This week I had the need to copy a load of messages from one SQS queue to another, below is the body of the Linqpad script I used to do it. void Main() { var seenIds = new List<string>(); var sidContainer = new DumpContainer("Seen Ids: ").Dump(); var sqsConfig = new AmazonSQSConfig { ServiceURL = "AWS_REGION_URL" }; var client = new AmazonSQSClient("A...

This week I had the need to copy a load of messages from one SQS queue to another, below is the body of the Linqpad script I used to do it. void Main() { var seenIds = new List<string>(); var sidContainer = new DumpContainer("Seen Ids: ").Dump(); var sqsConfig = new Am...