Wednesday, July 5, 2023

Notes to myself-from-the-future

The more code I write over the years, the more additional non-code information I tend to leave to myself from the future. The additional information, put in inline comments, comments in signatures, external markdown files, is intended to be targeted exactly to me from the future.

It usually starts when I look for something. Like for example - an ASP.NET application, something that looks like it works upon each request but there's no visible sign of a public http module registered in web.config. Since that's odd, I go to the global.asax and try to find a module registered programmatically (rather than declaratively). And then I remember - "wait a minute, I remember myself searching for the same information some time ago".

This is where I make a conclusion - if I search for something and I remember searching for it at least once before, I try to think like myself-from-the-future. Where would I search for this information next time? Well, I am in global.asax now, so there's a high probability that the future-me will also come to the global.asax.

I decide to use the global.asax then and I leave a note to myself-from-the-future - If you search for [....], this information is in [....]"

Looking for various information, I then am grateful to myself-from-the-past - I often just stumble upon these "If you search for ... this information is in ...." which means that at some point in the past I tried to think like the present-me and my prediction at that time was correct. And often, I have no memory of writing these notes, I just see them in the code, I belive I wrote them at some point, I can even check the source control and find the exact date. But I just don't remember writing it at all.

All these notes I send to myself, from the past to the future, are nice and useful and somehow let me feel like the past-me and the present-me is for sure the very same me, despite the time that passes. Things change but the way I think about myself is solid.

Today was the day I tried to find something in the code. The code is an old desktop utility app that registers some HTTP listeners at start. There are multiple places listeners can be added, in the Main function, in the main form's constructor, in the main form's load event etc. At first I've assumed the myself-from-the-past would possibly leave a note to the present me somewhere.

I've checked few obvious places. Is there a global markdown file for such notes? Nope. Is there a comment in the main *.cs file? Nope. Is there a comment in the form constructor? Nope. Is there a comment above the form class definition? Yes, there is but the summary section doesn't seem to contain any information about registration of HTTP listeners.

So I've spent like 3 minutes to track down the registration. Found a method that does it. Found a reference to the method. Tracked the reference, until I've ended up in form's Load method.

Just leave a note to myself-from-the-future - I thought. Next time I will try to search for it, I will probably go to main form class and a comment above it. The place that already contains the summary section but lacks the information about listener registrations.

So I go there, go to the very bottom of the summary section, since it spans a dozen of lines I carefully navigate to its ending to put a new line with the new information about the registration of HTTP listeners.

And guess what. The summary section ends, the remarks section starts there, a section I obviously missed few minutes eariler (I just haven't noticed it's there, I thought the whole green block of comment lines was the summary section)!

And the only line in the remarks section is: If you search for registration of HTTP listeners, it's in frmMain_Load

I swear it was not there few minutes ago ... But the fact that I've spent few minutes doing something I thought I hadn't done before but ultimately looks like I had, is kind of reassuring.

No comments: