Null reference exceptions considered harmful

Making a call to a service and getting a null result usually throws me, and when it throws me it usually means my code is about to throw an exception. This case applies especially to null instances of collection types. Why would you want to return null for a collection? I can’t think of a […]

Testing asynchronous JavaScript

By making AJAX┬ácalls directly to the server from your JavaScript view-model it can be impossible to get the code under test. A simple solution is to fake the calls and make them synchronous. This example view-model for a library takes a function that will make a call to the server to check out a book […]

Implicit casts for modifying legacy code

When dealing with legacy code it can be difficult to see where to make a change. Seeing and tracking the usage of a method /constructor parameter can require a skilled eye. It is sometimes easier (if possible) to change the value of parameters by changing their types instead to one which provides an implicit cast […]

The trouble with shims

Shims are described in Michael Feather’s book on legacy code as a stepping stone on the path to dependency inversion – they are a technique for breaking apart untestable code. Visual Studio 2012 ships with some libraries that are able to magically intercept and manipulate calls to code that are normally untouchable – even .NET […]

Annoyance with TypeScript classes

I have to say I really enjoy using TypeScript! I’m a big fan of static typing and appreciate the confidence it gives me whilst refactoring. Plus the intellisense help is of course useful for exploring APIs. It does suffer from downsides though. One of my bugbears is the complaints it gives when trying to dynamically […]