17
Nov

Clean Code and speed coding

   Posted by: Swizec   in Uncategorized

Some weeks ago I finished reading Clean Code by Robert C. Martin, which is something I may have spoken about already, but I can’t remember. Well it was an amazingly good read and it instantly changed a lot about the way I code and even the way I think about things. At first a lot of what was mentioned in Clean Code made the optimiser in me cringe and whince. Things like putting conditionals into a separate function and so on.

But later I realised that hey, modern computers are fast enough, some wasteful practices like that aren’t going to hurt too much and the saved time in development can only do good. See, the thing is that if, for example, you encapsulate conditionals in separate functions you don’t only achieve greater code readability, you also get the ability to change an important part of algorithm behaviour (when to do something) by changing a single function and the change automatically propagates throughout your code.

I believe that due to my new practices of writing code cleanly I have been able to develop Twitulater as much as I have in the past twelve days. It’s reached version 0.3 of all things and is fast becoming useful. So far the version update cycle, starting from 0.1, has on average been 2.5 days and that, if you ask me, is quite astounding – especially taking into account this is the first time ever of me developing in Adobe AIR.

The reason developing can be so quick once you acquire clean code practicess is mostly that, as Uncle Bob says, developers spend much more of their time reading code than they do writing it and when that code is super readable it takes much less time to read. Furthermore, due to many of his advice, the code is also much more searchable and better structured so it doesn’t take as long to find what you’re looking for – this especially applies to us text editor types who abhor IDE’s.

There is another reason that I believe is of even greater weight, now that I keep code clean I find that I can write large chunks of code, without testing, and have it working correctly the first time it’s run. With Twitulater it’s happened that I wrote a hundred lines of code, ran it, and it just worked, just like that.

Now all that’s left for me to do is acquire test driven development practices so I can cut my debugging time in half. Oh and if you didn’t glean from the rest of this post: You want this book.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • DZone

Tags:

If you liked this post you should follow me on Twitter,
or see the music I like on last.fm,
or perhaps leave a comment, I like comments,
or go do your job because I know you're slacking,
or go write a blog of your own,
or tweet about something interesting,
or go out and have some fresh air,
or find a girlfriend,
or a boyfriend,
or a manbearpig,
or for fuck's sake stop reading this already,
no?
This entry was posted on Monday, November 17th, 2008 at 10:21 and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed at this time.