Tips on writing annoying / difficult code

If you've been programming for any length of time, you'll know that eventually you will have to implement a particularly complex algorithm or conquer some other especially difficult challenge. Maybe it's implementing specular lighting, or perhaps it's fixing a nasty annoying bug in your physics engine.

Since I seem to have been doing this with increasing frequency at the moment due to University coursework, I thought I'd share a few things with you that I personally find helpful.

Plan out what you intend to do. Create a flowchart. Fill a whiteboard with notes. Talk to someone. Even if it's a rubber duck. Planning out what you want to do ensures that you have a clear idea in your head as to what you want to accomplish and how to go about doing it. It's very easy to fall into the trap of doing random things and just hoping that it will work.

Break the task down into steps. This goes hand in hand with the above point. Break your task down into small, manageable steps that you can follow one at a time to achieve your goal. I often find if I don't do this the problem I'm trying to solve looks an awful lot bigger than it really is.

Tackle the steps one at a time, and test regularly. Skipping to step 3 when you've barely started step 1 might be tempting, but it will probably cause more problems that it solves and lead to confusion. If you're thinking of doing this, then you might not have your steps in the right order.

Similarly, doing steps 1-4 before testing what you've done also isn't a good idea, because you might have made a mistake in step 1 that affects the output of step 4, and then spend an hour debugging step 4's code only to realise it is fine and it's actually the code you wrote in the beginning that is causing the problem.

I hope you find these tips helpful. If you did, leave a comment below!

Tag Cloud

3d 3d printing account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio automation backups bash batch blender blog bookmarklet booting bug hunting c sharp c++ challenge chrome os cluster code codepen coding conundrums coding conundrums evolved command line compilers compiling compression containerisation css dailyprogrammer data analysis debugging demystification distributed computing docker documentation downtime electronics email embedded systems encryption es6 features ethics event experiment external first impressions freeside future game github github gist gitlab graphics hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet interoperability io.js jabber jam javascript js bin labs learning library linux lora low level lua maintenance manjaro minetest network networking nibriboard node.js operating systems own your code pepperminty wiki performance phd photos php pixelbot portable privacy problem solving programming problems project projects prolog protocol protocols pseudo 3d python reddit redis reference release releases rendering resource review rust searching secrets security series list server software sorting source code control statistics storage svg systemquery talks technical terminal textures thoughts three thing game three.js tool tutorial tutorials twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 worldeditadditions xmpp xslt


Art by Mythdael