PowerPlant Debugging Classes
Volume Number: 15
Issue Number: 5
Column Tag: PowerPlant Workshop
PowerPlant's Debugging Classes
by John C. Daub, Austin, Texas USA
Techniques and tools to help you find and prevent
bugs
What We Have Here is a Failure To Deallocate
That line comes from infamous Coolhand Leak (see the help text for the "leaks
'dcmd'). And like it or not, things like this - bugs - happen. Humans write software,
by nature humans make mistakes, so it's a fair bet that there will be mistakes (bugs)
in software. Of course no one likes bugs, especially the users of our software, so it
behooves us programmers to do our best to write solid and bug-free code. I've found
three stages in which the programmer can work to make their code bug free: before,
during, and after coding.
Before coding requires proper planning and design in terms of interfaces,
implementation, tool selection, and so on. Some would argue this stage is most
important as starting off on the wrong foot is more difficult to recover from down the
road. During coding involves techniques such as performing assertions to validate
arguments and return values, checking for nil, and other processes that you can
perform while typing code. After coding involves such things as running under a
debugger or stress-testing/validation tool (such as QC or Spotlight), or worst case,
receiving a bug report from a user.
The core of PowerPlant mostly offers tools for the "during" stage. Looking in
UDebugging and UException, you find the core elements for checking errors, throwing
exceptions, and performing Signals (informational messages). These tools provide a
good foundation to help you write more solid code, but certainly more can be done.
Enter the Debugging Classes.
The Debugging Classes are a fairly recent addition to PowerPlant. They debuted on
CodeWarrior Professional 3, but I wasn't happy with their implementation. I have
since rewritten the classes, and the fruits of this labor can be seen on Pro 5, which
should be on your desk by the time you read this article. In this article, I'd like to
introduce you to the Debugging Classes and the wonderful tools they have to offer
towards helping you write better code, squash any bugs you may find, and hopefully
prevent bugs from happening in the first place. The Debugging Classes don't offer much
to help with the "before" stage (aside from the fact you should choose to use them), but
they do provide a plethora of tools for the "during" and "after" stage. The Debugging