Category Archives: Software

Netscape is Dead, Long Live Netscape!

Well, it is official.  The once-popular browser, from Mosaic through Netscape Navigator and all of its Mozilla variants, fought in the Browser Wars from 1994 through 2008, and is now throwing in the towel.  My once-favorite browser has finally fallen under the weight of Internet Explorer (and Firefox, too, I suppose). 

AOL announced on December 28, 2007 that as of February 1, 2008 they will no longer be providing Netscape Navigator.  Oh, how the might have fallen.  I found out about this on Engadget – Netscape finally bows out, browsers no longer supported, but you can read about it on the Netscape Blog – End of Support for Netscape web browsers.  The Browser Wars will continue, but without one if its original participants. 

The Lost Art of Debugging – Part 3 – Things To Do

As I have said before, debugging is a complex and time consuming process. I have outlined 10 resources for debugging, and provided a primer for things not to do when debugging. Now, we get to the meat and potatoes of debugging. This is a guide of things to do when debugging. I have broken this guide into three sections – a description of the Scientific Method of Debugging, Tips for Hunting for Bugs, and Bug Prevention Methods.

Scientific Method of Debugging

This is a parallel to the Scientific Method that you learned in your grade school science class. The book Code Complete by Steve McDonnell outlines this methodology to debug your applications.

  • Stabilize the bug by identifying the simplest test case that reproduces the error
  • Locate the source of the bug
    • Gather data about the bug and its behavior
    • Analyze the data regarding the bug
    • Form an hypothesis about the bug
    • Write test cases that would prove or disprove your hypothesis
    • Run the tests and prove your hypothesis, or begin again with a new hypothesis
  • Fix the defect
  • Test the fix with all of the new unit tests you have written
  • Continue to look for similar, cascading, or peripheral errors

For a more detailed breakdown of the Scientific Method of Debugging, read Code Complete by Steve McDonnell.

Bug Hunting Tips

These tips for finding bugs, broken out into different areas, will help you narrow down where your bug is.

General Tips

  • Be sure to save the original source code
  • Be sure the fix the problem, not the symptom
  • Make one change at a time
  • Check and Double Check your fix
  • Consider the possibility that the bug is generated from multiple sources
  • Divide and Conquer
  • Check other places where bugs have existed
  • Check other places where code has changed recently
  • Compile the application again

Logging

  • Insert Trace, Print, or Alert Statements to help track the bug
  • Create a logging methodology to trace the application
  • Check the Log Files of the servers, etc.
  • Search the web for the stack trace

Unit Testing

  • Design By Contract
  • Write unit tests that cause the error
  • Try to reproduce the bug in different ways
  • Try boundary cases and special cases

More Complex Methods

  • Recompile with a different compiler
  • Create a mini version of the application
  • Sequentialize the Parallel to see if it is a timing or resource issue
  • Try the code in different environments (local, dev, test, prod, other developers’ machines, etc.)
  • Grab someone else to talk through the bug without looking at the code (explaining the problem may trigger some ideas)
  • Do a full, in-depth code review on the broken code

Last Resort

  • Rewrite the whole section of code that is causing the bug
  • Take a break for a few minutes, or an hour, or until the next day, to give your mind time to process the data

Bug Prevention Methods

These are things that you should be doing during the planning and development of your applications that will help you identify, fix, and test your bugs after you are done with development.

  • Identify and track consistent bug types within your own code
  • Introduce debugging methodologies early
  • Implement loose coupling techniques
  • Implement Information Hiding Techniques
  • Write a regression test that tests the bug you just fixed

So… these are some different ways to attack debugging. Are there methods that have proven themselves that you have used? Do you take a different, more unique approach to debugging? What have your experiences shown to be your best practices? Please leave your feedback and let me know what you think.

The Lost Art of Debugging – Part 2 – Things Not To Do

Debugging is a complex and time consuming process.  In my last post I listed 10 Resources for Debugging, both web sites and books, that every software developer should read to keep their debugging skills sharp.  Knowing what not to do is just as important as knowing what you should do.  Here is a list of things not to do when you are debugging your application

  • Don’t guess what the problem is
  • Don’t dive into making changes without a plan
  • Don’t code right away without a thorough analysis
  • Don’t fix the shell of the problem, not the problem itself
  • Don’t trust line numbers in compiler messages
  • In fact, don’t trust the compiler messages at all
  • Don’t ignore the value of automated unit testing
  • Don’t delete the original code
  • Don’t ignore recent changes to your application
  • Don’t ignore resources available to you, like the Internet or the Library

This post is a teaser for the one that is to come – what thins should I do when debugging?  Is there a more formal process for debugging?  What steps should I follow?  What things should I look for?  What place should I look?

The Lost Art of Debugging – 10 Resources

Debugging is as much of an art as it is a science. There are lots of great tools to help developers debug their code. I believe developers, including myself, have learned to depend too much on these tools instead of thinking through the problem. There is a common thread across all programming languages and development platforms. That thread is the way that you approach, identify, and tackle a bug. To help develop an environment of good debugging practices, I have decided to write a series of blogs on technology agnostic debugging techniques.

My first post about The Lost Art of Debugging is a blogroll of resources, both electronic and print, that developers should read to help develop good debugging techniques. Here are ten great resources on the methodology of debugging.

Web Sites & Blogs

Books

Do you have other debugging resources that you depend on? Have you seen a great article on debugging? Do you have a debugging horror story you would like to share? Leave me a comment with your book, web site, or tale of woe.

7 Sources to Help You Conduct a Peer Code Review

The end of the year is swiftly approaching, and as the budget cycle is coming to a close, the work piles up quickly.  I have had a staff of three from January through August, and with the piling work, we have had to triple in size.  A staff of nine is very different to manage compared to a staff of three.  There are many things to wrangle during ramp-up: a new corporate culture, new policies, new development environment, new standards, new team members.  One of the tools in the technology manager’s arsenal is the peer review. 

The CodingHorror web site outlines why they think software development departments should perform code reviews in their article called “Code Reviews: Just Do It.”  Jared Richardson also describes the value of peer code reviews on his blog.  The basic reasons for implementing code reviews are obvious: reduced bugs, reduced rework, cross training, quicker ramp-up time, sharing of ideas, developer growth, mentorship opportunities, and team building.

Karl E. Wiegers has written a great article called “Seven Truths About Peer Reviews” available on processimpact.com that outlines a number of different methods to conduct your peer code review.  Some of the peer review methods methods he describes are inspection (both Fagan Method and Gilb/Graham Method), team reviews, walkthroughs, pair programming, peer deskchecks, and passarounds.  It’s a good read, and you should take a look.

Peer reviews do not need to be long, drawn out, complicated processes.  Jason Cohen describes some best practices for peer code review on his web site, SmartBear.com.  He has written a great looking book called “Best Kept Secrets of Peer Code Review” that you can order free on his site.  He recommends only reviewing code for five to ten minutes at a time, to keep everyone sharp, focused, and on point. 

You should definitely walk into your peer code review with a plan in mind.  Here is a Code Review Checklist for Macadamian that will help you organize your approach and keep you focused.

Finally, peer code reviews can be rough on the ego of the developer.  Here are “Ten Commandments of Ego-less Programming” based on Jerry Weinberg’s book , The Psychology of Computer Programming, from 1971.  This article describes how peer code reviews result in shorter project completion times, lower defect counts, and how developers had to set their egos aside to make it happen.

I am sure that code reviews will be good for my team, our projects, and our clients.  The hurdle is making them part of our development routine.  What do you think of code reviews?  Do you use them in your technology department?  What results have you seen?  Leave me feedback and let me know.

htmlSQL – Query your Page Elements like a Pro!

While stumbling across the InterWeb, I came across this really neat page.  The page, by Jonas John, describes htmlSQL, a PHP class to query the web by an SQL like language.  I know, I know, this is PHP, not C#.  But the idea really interested me.  I have spent a lot of time focusing on WatiN, which does a similar thing.  It allows you to take control of objects on the page and fill in forms, click buttons, etc.  Getting an element in WatiN requires you to search the page using the Find methods.  One of the troubles I have had is making sure that your find returns one, and only one, page element.  Being able to query the page with htmlSQL would be a great way to verify that.  A class like this would make it very easy to leverage the page DOM on the fly. 

Do you see any other uses for a class like this?  Are there other products like this?  What are your thoughts about htmlSQL?

Generating sitemap.xml files in C#

One of the things that I would like to tackle before the end of the year is including sitemap.xml files with all of the new sites that my team develops. We could generate these files manually, but this would be tedious at best. There are a number of tools that will generate these files for you. Some of them are stand-alone desktop applications (Sitemap XML). Some web-based tools are built in PHP (AutoSitemap), Perl (TM Google Sitemap Generator), Python (Google WebMaster Tools), etc., and you can use in your own local environments. There is even a web site that you can submit your URL and it will generate the sitemap.xml file for you (XML Sitemaps).

My requirements for this feature are pretty simple:

  • Something built in C#
  • Something we can include in our projects
  • Something that can be run as part of our build process
  • Something that can be completely hands-free

So far, the only thing that I have found is the GoogleSiteMapProvider on the CodeProject web site. This project:

  • [Is] instantly useable with the majority of ASP.NET applications
  • [Is] a full ‘binary’ solution – no integration of code or compiling – just drop in a binary, modify the web.config and go
  • [Is] extendable so that more complicated ASP.NET applications could redefine the provider without restriction

It seems like this is a great fit for our architecture. The solution was to have a single assembly with three main types:

  1. An HTTP Handler which would return the XML on request (called GoogleSiteMapHandler)
  2. A Provider Type (called GoogleSiteMapProvider)
  3. A Controller class to glue the Handler and Provider together

This is a great place for us to start. The source code is available, it seems to fit my needs, and is simple to use.

Anyone else using something different? Do you have any other ideas? Have you found any other tools that might be useful for this? Leave a comment and let me know.