Cart 0

The process

Posted by on

Many of the programming problems I have get solved through the process of writing code.

For example, say I want to make a page load faster. I look at the stack trace (the report that tells me which code is running) and see that there's a bit of code (called a partial) that's loading slowly. (It's running slowly because it's the code which loads the BIC and BISAC subject categorisation entries, of which there are over one billion, at the last count). So I think of ways I could make the page load faster. I know, I think. I'll load that bit which runs slowly *after* everything else has loaded. The user won't realise, because it's at the bottom of the page, and there's all the fancy fandagoes at the top of the page to keep them busy for the extra 2.5s this partial will take to load.

So I go down the rabbit hole of developing code to do my asynchronous loading, writing jquery calls, passing variables around. Time passes. Then I think hey, this is taking ages, and it's verbose and inelegant, and ooh, whilst I'm reading up on about this ajax call approach, here's an interesting thought about caching. And so I come up with another solution (fragment caching the partial using the instance variable which is the parent of the BIC and BISAC code forms, if you're interested). It takes one line, about 3 seconds to write, and speeds up the page loading just like the asynchronous ajax call would have done.

The idea was simple: speed up the page load. But in trying to satisfy it, the process took me down a number of dead ends. The act of trying to solve the problem led me to the solution.

There are parallels in writing. How many times has someone said to you 'oh, you're an author? I can't write very well but I've got an amazing idea for a book. Tell you what, I'll tell you my idea, you write it and we'll go halves'. Ha, bless him. He thinks that all you need is the outline of a story. He doesn't realise that the eventual beauty, the flow, the serendipity and the language of the thing comes from the work of writing the thing.

As with code, there's a lot of ground that has to be covered between the idea and its execution.

Share this post

← Older Post Newer Post →