Bug fixing tips and tricks to become a bug fixing master

Bug fixing is part of a developers job. Theres no escape from bugs cropping up here and there. Even the best developers in the world have to fix bugs! 

So... what can you do to make the war against bugs a little easier? We have put together some tips and tricks to help you minimise the amount of time you'll need to spend bug fixing and get back to development.

Enter the bug into your bug tracking software

Of course we would say that! Being a bug tracking software provider and all, but its good non-biased advice non-the-less. Being tempted to fix a bug straight away distracts you from what you were doing (unless you're bug fixing that is). You'll also have a tendancy of forgetting some details about the bug if you don't capture it in some way. You can also assign the bug for someone else to fix, which will allow you and your team mates to play to your skills.

Take a step back

Don't just jump straight in to fix the bug even if you are sure how to fix it at a glance. You may be wrong, and if you are wrong you might end up wasting your time on a wild goose chase. Think about all the possible causes for the bug and quickly jot them down. This way when you find yourself getting stuck you'll know where to start looking next. 

Break the problem down

Sifting through loads of lines of code to try and find the bug can be really daunting. Try and narrow down where the issue occurred by commenting out and isolating smaller chunks of code. If commenting out a particular chunk of code fixed the problem you know that code is interfering somehow and where to look. 

Google error messages

Its likely that someone else in the vast world of the internet has encountered the same error message you're looking at and already asked for help on a forum somewhere. Copy the error, and paste it into Google. If someone's struggled and fixed the error before make use of their learning experience. 

Don't hesitate to ask for help

A fresh pair of eyes and a different approach can work wonders and save hours of frustration. Don't be shy to ask colleagues and friends for help. Everyone's approach to solving problems is different, and theirs might be perfect to find the bug you're currently stuck on.

Stuck? Take a break!

Theres no point staring at the screen in confusion. No matter how hard you stare that bug isn't going to go away! Step away from the computer for a moment and go make a cup of tea, especially if you've started feeling frustrated. You'll have a fresh mindset to tackle the bug from a different angle, and I bet the fix was staring you right back in the face but you just couldn't see it!

Avoid guesstimating!

Now and then we are all put on the spot. "How long do you think it will take to fix?". Refrain from guestimating. Tell the one asking that you will need to investigate the problem first. If its a 5 minute fix you can fix it there and then and exceed expections, and if its a more complicated fix than you expected you can give a more accurate estimate now that you know.

Don't be scared to refactor your code

If you are finding your code difficult to debug its likely because it lacks modularity and is diffcult to read. Carefully refactor your code so that each function or method only performs one operation. This will make it much easier to isolate issues and will reacquaint you with your code.