Skip to content

Jamie Wright Posts

NUnit test cases

Testing multiple scenarios through the same function can be a bit of a time sink. Writing out a method for each scenario and just changing the data passed into the function then checking the output against the expected result. Steve Fenton showed me NUnit test cases the other day though which make running multiple permutations of data against a result set a breeze! They have been around a while I think, but I somehow missed that boat. See below for a simple example of how they work. The test above will check multiple combinations of inputs against the expected output…

Refactoring – Flocking rules

I have always been a fan of Sandi Metz, and have finally got around to her book 99 Bottles of OOP. A key takeaway so far from this has been the flocking rules for refactoring. The name derives from the small changes an individual bird makes in a flock that is then reflected by all the other birds so everyone ends up going in the right direction. The premise is fairly simple, make small incremental changes that only change a single thing a time. A lot of people think they do this already, however small is not small enough in…

C# Interfaces and default method implementations

The upcoming C# 8.0 release came up the other day, or more specifically the inclusion of default implementations on interface methods. At first glance it seems akin to madness, blurring the line between implementation and inheritance. We already have abstract classes that cater for this, so why the need? Taking a little time to dig a little deeper though, and I think it does make sense and could be extremely powerful. The caveat being that it isn’t abused, which it most certainly could be. Using it looks to be pretty straight forward. You simply provide a method body on the…

The fragmentation of UI frameworks and structuring for the future

The highway of UI Given the fast moving space in which modern UI frameworks operate, its more important than ever to have some methods behind the madness. Adhering to some SOLID OO principles to help keep code clean, maintainable and most importantly; separated from the functions of the user interface. The most important of these SOLID principles in this case is the separation of concerns. By keeping the actions of the UI separate from the logic behind it we allow portability. A lift and shift exercise can be reduced from a back breaking week to a nice easy afternoon. Great,…

Why Limit WIP

I have worked with WIP limits before without really understanding why we have them. They appear to be just some arbitrary number on a board that people roughly try to stick to with no understanding of why. Why is normally the most important question! Normally it is very hard to do the doing without the understanding of why backing it up. I am personally trying to ask why a lot more, and so I decided to pick up a book which was recommended to me, “Why Limit WIP: We are drowning in work” by Jim Benson. It is truly an excellent…

Critical thinking in software development

Critical thinking is a key skill when it comes to software development. Being able to diagnose a problem and find common causality can save hours of effort and frustration. However it seems to be a skill that is often overlooked and undervalued. Sometimes you hear the phrase “10x” developer thrown around. This is a developer that can do ten times the amount of work in a given time than an average developer. Whether or not this is true is another argument altogether, however I would suggest that critical thinking skills and not development skills would account for much in this…

Javascript custom event handling in IE

Events can be extremely useful in Javascript, and most browsers implement them naively. Here is an example of an event that fires when the number of vehicles change. This will work on every single browser, except IE. It even works on edge.  If you run this in IE 11 or lower you will receive an “Object does not support this action error”.  To get around this there are two options. JQuery or using a polyfill. For simplicity, cross browser support and the general pervasiveness of JQuery, the first approach is generally the best approach.  You can implement the equivalent above…

Coding standards in Javascript

This is more of a plea than a post, but I would like to impress upon you something important. When it comes to Javascript, please do not throw everything you know about good OO practice out the window! Javascript has gained a bit of a reputation for being misused. It is almost understandable, as it is so easy to do things that you know you really shouldn’t. Oh look, a shortcut! Bad idea. When you come back to try and untangle this shortcut later, you end up with a patchwork of dependencies. The whole thing becomes a nightmare. Once you…

Exception handling in Web API 2

REST Web APIs are becoming more and more popular and have seen a large uptake recently. One of the nicer features that is available in the .NET web API 2 toolkit is it’s inbuilt exception handling. This allows you to maintain separation on concerns and stops controllers becoming bloated beasts of burden, or logging. A common scenario for people who have just started to build Web APIs is to blindly implement try-catch exception handling. This might look something like this As you can see, the actual code that performs the action that we want for this controller method is only…

Hello World!

Yes, I am probably not the first and nor will I be the last. However, I feel the title of a programmers first blog post is almost as certain as the first piece code he/she will ever write. I can’t escape the feeling that I would be disappointed to find out otherwise. Having spent a bit of time in the software industry now, I feel better equipped to give my opinions on various topics. I can hopefully provide help to people who might be struggling with a particular issue. (Hello all you frustrated googlers!) In this blog I will be…