CS 4448 - Spring 1998
Object-Oriented Programming and Design
Discussion 11.2.1
by
Hoonil Kim
Code that Tests Itself
by
Charles Weir
- Questions were raised about how assertion in MFC environment works and "Is the assertion
always handy to debug some errors in code?". In MFC environment, when the assertions are occurred
with some error in code, system pops up a dialogue box saying "OK" button to debug the errors and
"Cancel" button to ignore the errors. With "OK" button, it runs debugging tool in the system and
tells you what and where the errors were. However, that is not always handy for C++ programmers to
figure out some assembly code which is corresponding to the errors occurred on the assertion.
- Another point we discussed was the difference between assertion and invariants.
The assertions do verify that something is true at a specific location in code, while
the invariants do verify something that is true of any instance of a class.
- Obviously, the assertions and invariants are really necessary to debug some errors in code, so
implementing the assertion in C++ are very important to get as much information as possible about
the problem.
Copyright © University of Colorado. All rights reserved.
Revised: April 2, 1998