Visual Basic IDE Tracing
The Visual Basic Integrated Development Environment (IDE) provides the Visual Basic
programmer with a vast array of tools for creating, unit testing and debugging applications. To achieve
rapid development of solid code requires programmers to both master the IDE and apply
good development technique. Programmers must therefore be expected to take full advantage
of the Visual Basic IDE's capabilities and encouraged to do so.
Single Step To Success
Single stepping through the execution of your code is a sure way of gaining a better
understanding of your code and of proving its correctness. Studies show that developers
who take the time to single-step through code execution typically produce code with
lower defect counts. This is achieved through better understanding and because defects
are identified and fixed far sooner in the development process.
Another important reason for stepping through code execution is to ensure requirements
of both design and function are being met. IDE tracing serves the purpose of both a miniature
code review and a functional test review.
Failing to meet design and functional requirements
at time of coding will add delays and costs downstream if not identified and corrected
early. Finding bugs during coding is therefore not something to be ashamed of but is rather
something to be encouraged and also to be pleased about as unscheduled delays and costs
downstream can be avoided.
By tracing code execution within the IDE complex and inefficient code can soon become apparent,
as can code which is "working" for the wrong reason. Alternative code paths can also
be identified and tested.
Get Immediate Results
The 'Immediate' window of the IDE offers a work bench from which to hand test procedure
calls. This is an ideal means of unit testing procedures to quickly obtain results and
ensure all code paths through a procedure are executed. Adding debug trace messages
(via the 'Debug.Print' statement) can aid verification within the Immediate window and
you can also use the 'Watch' window and breakpoints to further verify correctness
during execution.
Be Assertive
The Visual Basic 'Debug.Assert' statement is a powerful ally to the defensive
programmer allowing unexpected conditions to be trapped quickly during debugging
within the IDE. Assertions also help to document the assumptions and expectations
of a procedure.
No one has a better understanding of a procedure than the original author at
the time of writing. If care is taken at time of writing to trap unexpected conditions
and to document procedures with suitable header comments then future developers
will quickly identify and eliminate defects caused by any initial
misunderstanding of procedures.
Share Knowledge
Stepping through code execution within the IDE represents an excellent opportunity
to share knowledge with trainee developers. Whether you choose to explain coding standards, demonstrate keyboard
short-cuts, debugging technique or error handling strategy (to name but a few), making time to share
knowledge is an essential part of the learning curve necessary to convert trainee developers into
experienced professionals.
Conclusion
By exploiting the full capabilities of the Visual Basic IDE, programmers can successfully
trace code execution to verify code meets both design and functional requirements. Problems
can be identified quickly and early in the development process thereby avoiding unscheduled
delays and costs downstream. IDE tracing also provides an ideal opportunity for sharing
knowledge with trainee developers.
|