Matthew Lang avatar

Matthew Lang

Family guy and web developer

Don't Strive for Perfect Code

Striving for perfect code is a goal of many developers and programmers. We want our code to be simple to read, concise using the best idioms that our programming language has to offer and of course backed by an army of tests to prove it works. You want your code to be perfect. This is achievable in our own projects and products that we have invested our own time in, but what about work for clients and employers?

Your development time is measured as a resource whether you are a full-time employee or as a gun for hire freelancer. How do you justify spending hours getting the code you have written to be the most perfectly implemented code you can achieve?

You don't.

As an agile developer, the code you have written should be testable and easy to read. With a little bit of extra time, it should also be concise to the point where you have re-factored duplicate code, extracted some methods and maintained basic programming principles but also ensured that it is still readable. So what about taking a step further and making it even better?

Hold fire. The code you have written for the feature or bug or whatever it was is now working and tested. You've spent a bit of time refactoring. Now commit your changes and move onto the next card for the application.

In your eyes you have committed sub-standard code. With a bit more time you could have taken it further and made the code better. This path can go on and on if you're not careful.

In your client's eyes or employer's eyes you have committed working code, you haven't taken too much time to do it, and it works. They will be happy with your efforts.

The perfect code you are aiming for is never going to perfect and nor will it last. In a few months, the framework you have written your code with is going to be updated. Chances are the perfect code you have written could be improved upon again. In a year or two, the programming language your application is written in is going to be updated. There goes your perfect code. Then when the programming language has been superseded by a new kid on the block, the application you invested so much of your time in is rewritten in a different programming language. Your perfect code is gone forever.

Unlike the written words of Hemingway or Tolkien that have endured decades, your code is simply a stop gap to making a product or service operational. By all means exercise some time to make improvements on the code. Remove duplications, re-factor it, but always keep an eye on the clock. Spending too much time trying to achieve perfectly written code is not a good use of your time or the time of your client or employer.

The wrong approach

The wrong approach. It's a major downfall of mine. Trying to solve a problem by approaching it wrong and looking for a difficult solution. The thing is I'm not looking for the difficult way to solve the problem on purpose, I just keep happen to be looking in that general direction.

Take the problem I had today.

For three hours I tried to find the solution to a problem I was having in a clients application. I spoke to the client at the end of the day to give them an update on my progress and five minutes after the call the solution was clear.

The client didn't provide the solution. It was just one of those moments when everything fell into place and all of a sudden the solution became clear. I wish these moments presented themselves more often.

The truth is I simply need read up more on the programming languages and frameworks I'm working with on a daily basis. The everyday knowledge only gets you so far. When you've exhausted that you need to look towards the more advanced parts. It's only when I learn these advanced parts that I will truly rid myself of looking at problems with the wrong approach.

Time to leave Twitter?

It's a well known fact that if you're a reader of my blog, you'll know that I love the App.net service. A subscription based network for those that want something more than just ads in their timeline. Since taking up residence on App.net, I've found that I am no longer as active on Twitter.

These days I check it about once a week. Only out of habit really. Previously I was following just 50 accounts on Twitter and today I cut that number in half. I'm now following just 25 accounts. The plan over the next few weeks is simply get this following count down to zero and then delete my account.

I just don't get as much value from Twitter these days. I don't find client work on Twitter, I don't use it for marketing myself as a freelancer (that's what my website is for) and it's been a long time since I marked anything as a favourite there. Really it's just another placeholder for me on the web, but is it really that important to have a Twitter presence now? Once I delete my account it will be gone forever. I might be lucky enough to get my username back if I sign up again but the chances of that happening are remote.

Anyone else out there considering giving Twitter the chop?

I've adopted this idea of Patrick's for my own stuff. The card only contains things that I want to do personally for that day.

Client work goes in my Moleskine where I need a more permanent record of day to day progress.

Starting a re-design

After reading Matt Gemmell's post on designing blogs for readers, I decided to assess my own blog for a re-design.

Here's the parts of my blog I'm not that happy with at the moment:

  • I used another template for my site that was similar to the default Octopress theme. They're fine themes to use but I've always wanted to design a theme that suits my requirements.

  • The side bar is a busy place. Perhaps too busy. While I do want to have extra information like links to other accounts and other information, I feel this information would be better suited at the bottom of the blog. This way the reader isn't distracted during the reading of my post.

  • The fonts used in the current theme make it difficult to differentiate headings from paragraphs. Easy to fix, but I don't want to put a band-aid on the current theme. I want to start from scratch.

With this information I've decided to put together a new layout for the site over the next few weeks. I'm putting a couple of products to the side for the moment. For the next few weeks I am really busy with client work, so I want a side project that doesn't demand too much of my time. This will fit the bill nicely.

A great idea: Weekly pricing

Dedicating yourself to a project weekly means you don't have to switch contexts. I wake up in the morning, get myself ready and then I start on the tasks for a weekly project. I don't have to decide what clients gets my priority today, I just work on the project for the week.

Weekly Pricing for Web Development by Curtis McHale

I love this idea. Basically it amounts to charging for iterations or sprints. Nice to see Curtis picked up on my task switching post as well.

I can afford to lose some time during the day as I am working with mostly one client at the moment on a number of their applications, so a little lost time is to be expected.

Tonight I took the final step in making the move away from Google. After much deliberation I made the move to migrate my Google Apps email account to FastMail. It was certainly less painful than I thought it would be and took the best part of an hour to get all three email accounts over to FastMail.

As for the other services from Google, I've found suitable replacements for many of their services over the last few weeks.

  • Switched to Pages and Numbers from Google Docs - I don't have that many documents to manage and I don't need them when I am on the move, so setup will be sufficient.
  • Switched to Feedbin from Google Reader - Feedbin is still young but it's growing and it's supported by the Reeder app for the iPhone. A no-brainer decision there.
  • Switched to Gauges from Google Analytics - Github's analytics service is ideal for my needs at the moment. It's dashboard provides all the information that I need at a glance and of course it has a greap API that's easy to use.

There are of course other Google services that I never really took too like Google+, Chat, Picasa, and their Drive service. I already use alternatives for these that I find to be much better so I never really got round to using these.

So why move from Google?

It was the all your eggs in basket argument. Google aren't going to go away anytime soon, but simply having all my information in one place was nerving. I wanted more control over my data, so I elected to find alternatives that would do just that.

I'm happy with the choice that I made in Google free. It's not for everyone, but having more control and investing more into products and apps that provide a better service certainly does give a better feeling than handing all my information over to one provider.