Debugging hacks – aka, do I understand how my code works?

Seen on Twitter this morning with guilty amusement:

 

Made me laugh as I thought of blocks put into my Docker files to let me go in and see what state things were in after I ran them.   Move 2 lines of code around from place to place and see what new info I glean…

#####DEBUG - exit here to check state
exit


Or console.log statements with odd text that should _never_ make it into checked-in code, but acts as a visual trace of the flow of code.

Or conditional asserts put into code to verify that a condition really does happen on the Nth +1 iteration of the loop.  (Handled with less danger of an inadvertent code check-in by setting these up as conditional breakpoints in a debugger..)

Or even comments added in to help us better understand what we think we’d like to keep versus toss in a burning hole.  (Source of comments: Apollo 11 Guidance Computer source code…  Way before my time, but demonstrating another ancient programmer spell…)

Got any new tricks to add to my bag?

Leave a Reply

Your email address will not be published. Required fields are marked *