Looking for Snippets of Code By Reading Code Backwards

This snippet is more for the beginning to moderate code writer from a programmer who can sometimes be overly dependent on MS Excel to get things done! (Eh?) You'll see.

The other day I've had the special opportunity to read some computer code backwards.

I had to read it from the bottom up because what it did was demonstrate a certain order that data was being written out by another piece of code, which is what I really wanted. This first piece of code read for the last possible output written, and worked it's way backwards until it found the last piece of work. Effectively though, it showed me the streaming order of data.

Reading code ain't all that hard, but the logic of it is a bit confounding. I had a lot of things going on at the time. Since I knew what print statements I needed to find that told what what was happening when, I cheated a bit and did the following:
  • Opened an Excel Spreadsheet
  • Copied the code into Column B, (Paste Special, text only)
  • I then numbered the rows in Column A., in this case 1 to 547.
  • Sorted the whole mess based on Column A, but in Descending Order.
  • I then sorted the whole mess one more time,
  • Primary Column B, Ascending; Secondary Column A Descending.
This pulled out my print statements, and showed them in reverse order in the code, but in reality, showed me how they were produced in real time order by the other originating code stream.

Walla! Sanity sort of saved.

Comments