Archive for the ‘Uncategorized’ Category

This blog has a new home

Sunday, May 4th, 2008

This blog has moved from it’s old home at http://stephendoyle.blogspot.com to its own domain at http://softwareramblings.com. The move should be transparent to subscribers of the feedburner feed - at most there will be a few duplicate entries in the feed as the old posts are imported into the new setup.

So why the move? The main reason was because I found the blogger interface a bit cumbersome for posts that involved source code. I was underwhelmed by the presentation of source code that resulted from <code> and <pre> tags. It was also a pain to have to remember to properly handle the angle brackets and ampersands in the code. I decided to move from blogger to WordPress so that I could take advantage of it’s syntax highlighting plugin which is based on the syntaxhighlighter Google Code project by Alex Gorbatchev. Check out the following snippet - cool or what?

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World" << endl;
    return 0;
}

Rather than moving the blog from stephendoyle.blogspot.com to something like stephendoyle.wordpress.com or softwareramblings.wordpress.com I decided to move the blog to it’s own domain. Since the blog was entitled “Software Ramblings” and the domain of the same name was miraculously free, my mind was made up.

5 Generic Debugging Tips

Saturday, December 8th, 2007

These are some practical tips to help maximise your chances of success when debugging software problems - especially those hard to isolate problems. Most of these tips will seem like common sense but I am constantly amazed at how often they are overlooked! I’ve deliberately tried to keep these at a generic level and not tie them to a specific language so that they may be of relevance to most people.

  1. Think: If you can quickly build and test your application there is often the temptation to keep trying things until the bug goes away. It is easy to get caught up in a cycle of “make a change - build - test (fail) - make another change …” without really stopping to catch your breath. The danger with this approach is that when the bug goes away it is sometimes difficult to tell if the bug is fixed or if you have just solved a symptom. Although frustrating, it is sometimes a learning experience to have to debug an application or system that takes a long time to rebuild and test. This forces you to take a step back and to think carefully about what you can glean from your current data and what the next step should be. This will help you to better understand the nature of the problem and in doing so it will help to find the root cause more quickly.
  2. Baby Steps: This is a really obvious but often overlooked practice. When debugging always take baby steps and only change one thing between tests. It is often very tempting to make a couple of changes or to skip a step, but this invariably results in an inconclusive test result and you will end up backtracking to figure out which change caused a change in behavior.
  3. Simplify: Try and reproduce a suspect piece of code in a stand-alone environment. For example if a particular algorithm is miss-behaving, try and replicate this behavior in a simple application that only contains the algorithm and may be easier to control and debug. Similarly, if debugging issues in a kernel, it is often possible to replicate the code at a user level which is a much more friendly debug environment.
  4. Tools: Become intimately familiar with your tool chain. Take time to learn the power and quirks of your unit test environment, debugger, memory leak checker, compiler, etc. If you develop on multiple platforms and use different tool chains on those platforms then learn them all!
  5. Challenge Assumptions: Assumptions can be dangerous. How many times have you assumed that a particular piece of code is working only to find you many hours later that it contained the bug that was the root cause of the issue you were debugging or that it behaved subtly different than what you expected? In general it is good practice to assume nothing and to challenge all assumptions that you find yourself making.

Always an apprentice?

Saturday, July 14th, 2007

With the rate at which new software languages and technologies are appearing, its a tough job for a software engineer to keep up with the latest developments and trends as well as keeping existing skills sharp. Just as you feel you master one language or technology, a new one comes along and your apprenticeship starts over in this new field.

One of the best ways that I have found to both learn new languages/skills and to keep existing skills sharp is to practice each skill as much as possible. For programming languages this means regularly writing pieces of code in each language in the toolbox. I try to use each language that I know at least once a month for languages that I have become proficient in and at least once a week for languages that I am learning.

Dave Thomas describes this concept in greater detail in his CodeKata series.

I find the use of programming puzzles and challenges as excellent ways to find concise coding exercises that don’t soak up to much time but yet provide opportunities to hone & develop skills as well as often providing opportunities to learn about new libraries, packages, algorithms etc.

Some of the best coding problem / challenge sites that I use are:
http://codekata.pragprog.com/
http://www.pythonchallenge.com/
http://www.topcoder.com/