Category Archives: Software

Code Coverage with QUnit and Blanket.js

I’m a big fan of automated unit testing. I don’t always develop test-first, but I do always try to make sure I end up with a good set of tests for whatever code I’m writing. For JavaScript (in the browser), I’ve settled on QUnit as my unit testing framework of choice. It’s easy to use and works well.

Ideally, you’ll have tests that cover every part of the code. For some projects, it’s pretty easy to tell when this is the case. But if you find yourself writing tests for a complex piece of code that didn’t have many (or any) tests beforehand, as I did recently, then it can be good to know exactly how much of the code is being tested, and which bits still need to be exercised through tests. This is where a code coverage tool comes in. Continue reading

Idea: Smart Paste Tool

One of the first things I install whenever I find myself in front of a new Windows PC is PureText. It basically gives you a shortcut keyboard combination for “Paste Special -> Unformatted Text” which is something I find myself doing quite a lot. I hate pasting from one application into another and having all the formatting come with the text, and PureText solves that problem really easily. I now use it just about every time I paste. I think of paste as Windows-V now, instead of Ctrl-V. I felt a bit lost when I got Windows 8 at work and PureText didn’t work at first (it’s been updated now!)

idea

PureText works by modifying the contents of the clipboard before pasting. This got me thinking about how else you could manipulate the clipboard when pasting. I thought it might be useful to have a utility which allowed you to set up a list of items. Each time you paste, the next item from the list would be placed into the clipboard ready for the next paste. Instead of lists, you could also set up expressions which the tool uses to create the next item, with some useful variables available, such as the index (the number of pastes you’ve done so far). Continue reading

Fixing Marginal Issues

Sometimes when you’re programming (or working on any project, really) you’ll discover some feature or issue that requires a lot of work to do properly. It’s often something that you completely overlooked during your initial design work, a tricky bug that came up during testing, or a use case that only some users will find.

A few months ago I made a simple Rubik’s Cube page and put it up on the web. More recently, I discovered it had a bug; a pretty serious bug that meant it wasn’t doing at all what it was supposed to be doing, namely simulating an actual Rubik’s Cube. Fixing it was hard. It meant rethinking the entire design of my code. I spent more time fixing this bug than I did on the entire first version of the project. At the moment I’m wrestling with a similar issue on my current project. To make it work well in 100% of all possible use cases is taking considerably longer than it took to make it work 80% right. Programming projects are full of these types of issues that look simple until you start working on them and realise they’re not. Continue reading

The Little Schemer and The Seasoned Schemer

I’ve been working through these two programming books, on and off, since some time last year. I’ve just finished the second of the two, so it’s time for a book review. I’m considering them as a single book because they are both fairly small, and one continues right after the other; even the chapter numberings continue across the two books, and functions from the first book appear in the second one. I took a few months gap between the two books, but it’s probably better to continue straight on so the concepts from the first book are fresh in your mind.

The Little Schemer book coverThe books use the programming language Scheme to teach certain interesting programming concepts. They’re not designed to actually teach you the language, although I’m sure the material covered will be useful when I do go on to learn Scheme from a more practical point of view. The first book, The Little Schemer, is all about learning to think recursively, while The Seasoned Schemer is more about functions, and also covers state and continuations. Continuations in particular were a new concept for me before I started the book. Continue reading

Teams of Three

I’ve worked in a number of different software development teams, and some of the best have been when I’ve been part of a team of 3 people. In this post I discuss some of the features of such teams, what helps them work well, what can harm them and my subjective experiences of working on such teams. I can’t say categorically that 3 is the optimum team size. Clearly, the right size of team is going to depend on many things. But if you happen to be on a team of 3, or you work with one, this might be helpful.

Teams of 3 Are Self-Organising

A long time ago, in a book I’ve long since forgotten, there was a diagram about team size and the number of communication channels required to keep each member informed. It looked something like this:

As the number of team members goes up, the number of communication channels increases exponentially.

As the number of team members goes up, the number of communication channels increases exponentially.

Continue reading

How to Find Bugs

Your code has bugs in it. Here are some ways you can find them.

Test It Yourself

I do two things to test the code I write before anyone else sees it. First, I tend to write automated unit tests as I go along, in a kind of test-driven development style. These don’t so much find bugs as prevent them from occurring in the first place, as they force me to think about the requirements the code must fulfil before I write it. They are probably at their most useful though when you discover a bug through other types of testing. Then you can use a new unit test to reproduce the bug, fix it, and be confident that it will stay fixed through future versions of the code. Continue reading

Multitasking and Focus

Recently I was working on a tricky problem. It was one of those problems that only occurs on a test server but not on a development box. Since the test server was hosted on Azure (the same as our live server), this made it really tricky to debug. Doing a manual deployment to the test server takes about 40 minutes. So my write-test-debug cycle was about an hour! To make things worse, it was an intermittent problem, so I could never be 100% sure when it was going to occur. And to make things even worse, I discovered that the only way to reliably get the problem to occur was to do another deployment. Simply stopping and restarting the server, which would have been much quicker, didn’t have the same effect. Yet another complicating factor was that the error that occurred wasn’t in our own code, but instead it seemed to be in some other code that was executing when a page was loaded, before our code ran. So the call stack in the exception was a load of functions in the .NET framework that I couldn’t get at.

All of this meant that I had to treat this like a science experiment: Get as much info out of the system as possible, with some hacked in debug logging, to try and find out where the problem was occurring. And try various things to see if I could get the problem to occur consistently and (eventually) to make the problem go away consistently. This involved a lot of deploying of slightly different versions of the code! Continue reading

Why I Prefer Fixing Software Than Hardware

I was having a conversation recently with someone and we got onto the topic of how someone who’s smart and good at building things in software isn’t necessarily good at making or fixing hardware (by which I mean anything physical, including home improvements etc). I’m one of these people. It seems like many of the skills should be the same: the ability to visualise the desired end result, putting smaller pieces together to make the whole, the curiosity and intelligence to figure out how things work, the patience and concentration required to complete the job. But they are still different skills and both require different types of practice to get good at them.

Generally I believe that anyone can learn any skill if they’re prepared to practice. However there are many aspects of working with real physical things that I just plain don’t like and, when compared to software, annoy me too much. So I’ve never really been motivated to practice and get good at them. Continue reading

Premier League Race Animation

Sometimes football TV pundits talk about “the Premier League race” as though it were an actual race between the teams, rather than just a list of teams sorted in descending order of points. I thought it would be interesting to see what a Premier League season would look like if it actually was a race, so I decided to make a little animation. This post is a write up of how I did this. If you want to go straight to the animation for the 2011-2012 season you can do so.

I chose to implement this as a web page, with the animation stuff written in JavaScript. I wanted to use it as a practice project for getting good with web technologies like HTML, CSS, JavaScript and jQuery. It turns out I also used some PHP to process the result data and generate the web pages (although I could have used any language for this part because the PHP is just used to generate static html files; there’s no dynamic server-side code running). Continue reading

Web Design Templates and the Purist

While I’m reasonably skilled at working with HTML and CSS code, I’m a hopeless graphic designer. I have tried to make nice looking websites in the past, but they always end up looking ugly. My attempts at minimalism come out boring, and my attempts at exciting look busy and confusing. And besides, I’d rather work on code than design anyway.

So I make use of the many available web templates from sites like ThemeForest. These always look amazing in their demos on the site, and I can usually find something that suits whatever project I’m working on. But it’s not quite so simple when I come to work with these templates for my site. Continue reading