I spent a good hour today trying to get some old code working and got stuck trying to fix:
a CFML variable name cannot end with a “.” character
Can you spot the issue in the following code block?
The 5th line has an extra space in between the struct name and the key name. To me, the source of the error seems rather obvious now. It wasn’t very obvious at all when I had to find this tiny space in several thousands of lines of code.
If you are curious to the manner in which I figured this out, I relied on an old standby, Divide and Conquer.
The Divide and Conquer method of debugging involves removing 50% of the source code (and still leaving a runnable application) then executing the process. Does the error remain? If so, put the removed code back, and chop out the other 50%.
Does the error still remain, if so, we’ll label this chunk of code the Problem Set. Put 50% of the Problem Set code back and run the process again…
Wash.
Rinse.
Repeat.
This debugging technique is most useful when:
- You are looking for syntax errors or CSS/HTML errors
- When you have no context as to how the application works, or what it does
- When you’ve been overanalyzing and underfixing