2006-03-01

ASSERT II : Conditions, conditions, conditions,,,,,

One bit of program design that should be habitual is the use of pre-conditions and post-conditions in functions.

Pre-conditions are the guarantee that your function is getting it's objects in an expected manner. This will cover both any inputs to the function and any class objects or global objects that the function is expected to use.

Post-conditions are the guarantee that objects will be as expected when leaving the function. Again both the function output and objects external to the function are covered here.

One minor detail on this. Remember that Debug and Release versions of a program are usually different. If you are keeping an eye on pre- and post-conditions for Debug versions of a program, it is highly recommended that the same conditions are handled for the Release version as well.

No comments: