TechHui

Hawaiʻi's Technology Community

Being able to solve problems and fix bugs is probably high on the list of things that make a programmer a good programmer.   These days programming is assisted with many tools and techniques.  Stepping through code using advanced IDEs and debuggers find many issues before they become issues.  Intellisense, code completion and syntax highlighting also reduce bugs before they can become bugs.  Exception handling and error logging help a lot when issues occur in programs.  Testing frameworks and methodologies help us to validate code and functionality in addition to lessening the introduction of additional bugs.

 

What happens when all of that fails or when we are given an application we are not familiar with or is not debug or test friendly?  What types of non technical techniques do you use when attacking a difficult issue?  Here are 10 things I find myself doing when confronted with a hard to find bug.

 

  1. Compare files and environment.  Make sure your code is exactly the same as the code where the issue takes place.  If possible make sure your environment is also the same.  Pay attention to configuration and versioning.  Sometimes it’s not the code, but mismatched versions.

  2. Try to keep things simple.  Some of the worse bugs are the ones with simple solutions.  If you find yourself coming up with complicated solutions to fix a bug step back and consider whether things really need to be complicated.

  3. Don’t rush.  Not many people work better when they rush.  Take enough time so that you don’t skip over obvious issues.

  4. Keep your users in mind.  As a programmer we tend to know how a program works and will often avoid doing things that will break things.  Trying to remember that users will always do things in a way that was not expected can help to open up possible issues.  Make sure to get detailed reproduction steps and details about the user’s environment.  I always try to remember the Who, What, When, Where, Why and Hows of an issue.

  5. Remember that if something is going wrong the majority of the time it’s not the computer’s fault.  We may sometimes come across an error where we think it’s an issue with the framework or something out of our control.  Unfortunately it’s more likely there is an error in our code.  Remembering this can prevent going down paths not related to the issue.

  6. Do things an alternate way.  If the functionality is simple enough explore doing it an alternate way.  This will help to uncover what the program needs to do.  If your alternate way exhibits the same issues you can narrow down the causes.  Even better if your alternate way ends up working.  Even if you don’t write any alternative code, just thinking about it can help to solve the issue.

  7. Break things down.  If you have unfamiliar or complicated code it may help to break it down into its simplest parts.  Take out everything except for the basic functionality and build back up to see where an error is coming from.  Sometimes it helps to isolate code.  Take it out of the application and put it into an empty application to see what happens.

  8. Have someone else look at the issue.  Sometimes focusing on an issue results in focusing on an entirely wrong area or becoming blind to an obvious bug.  Having someone else look at the issue can bring new things to light.

  9. Break things.  Breaking code can sometimes help you to understand code far better than only reading or stepping through code.  Like reading a book we tend to overlook things that we have seen countless times before.  Breaking something on purpose can help to break out of the mentality that you think you know how something is working and open up new ways to attack the problem.

  10. Take some time away or sleep on it.  This may not be an ideal method when you have a deadline, but many times taking a break from trying to fix a bug results in fresh perspective needed to find the solution.  Resting your brain and destressing also helps.

 

Do you have any techniques that you use to make those invisible bugs visible?



Views: 173

Comment

You need to be a member of TechHui to add comments!

Join TechHui

Comment by Tom Bodine on January 16, 2015 at 1:28pm

"Keep your users in mind. " This is probably the most important thing to remember. It is always helpful to find some one who is unfamiliar with the code, to try out the application you are working on. The less technically savvy the better. These are the folks who will find the holes you left in your code. You eliminate the bugs found first and you will have happy customers.

Comment by aron nelson on November 27, 2014 at 8:52am

For me, version control like David said, is my greatest asset. I am always amazed how one line can affect the usability of my app - and that one line was used many times in the past with no ill effects. So I disregard it, only to find out that it caused all of my problems now.

Comment by Joseph Lui on November 10, 2014 at 11:34am

:+1: Words of wisdom.

Comment by David Chung on November 9, 2014 at 9:48am
My go-to advice is to use version control with continuous integration even on your development branch and submit small changes. Go as atomic as you can.

Made a name change? Submit it. The expression is now a multiplication? Submit it. Added a new test? Submit it.

You will have many commits but as long as you're also maintaining test coverage, you should at least minimize debugging sessions.

For me, unit testing is the ultimate debugging tool as you make assumptions about a unit and verify. If that unit is doing something else, then you've isolated where you need to debug. With continuous integration, you can catch these anomalies early before it becomes harder to find.

Sponsors

web design, web development, localization

© 2019   Created by Daniel Leuck.   Powered by

Badges  |  Report an Issue  |  Terms of Service