Fence Post

The FencePost technique is a common debugging pattern. To find where an error is occurring, put some code in your program that will let you know if it has occurred. This might test a condition, just print out the name of the function (if the program is crashing), but it should let you know when the program is OK, not just where it is bad. Once you get a range on the error, i.e. get it between two FencePost's, you put in a (or many) new FencePost between the other ones, and narrow the range.

Every experienced programmer knows this pattern, but new programmers usually have to be taught it.

Also see BinaryChop.

This is especially useful when you don't have [a desire to learn how to use] a debugger. Beware of using FencePost to find HeisenBugs.


See also FencePostError


CategoryDebugging


EditText of this page (last edited January 14, 2006) or FindPage with title or text search