I have a really terrible memory. I am reminded of this whenever I find myself searching our git repo because I am hoping that someone has written a particular helper function, and I find one, and the author is me, from two years ago.

I think, past-me sure was kind to present-me.

But that's not usually how it goes. Past-me is usually a jerk.

So in an effort to prevent present-me from being a jerk to future-me, I am trying to learn some lessons from past-me's previous jerkiness.

Lesson 1: Programs/classes/files/functions never get smaller, only larger. Whenever I find myself thinking "I wonder if I should break this into two pieces to make it easier to read", the answer is almost always yes. It may not seem so when it's 100 lines of code, but future-me will probably be looking at a 1000-line monstrosity and it'll be a lot harder to peel it apart after another dozen people have modified it. Or even if it was just me: see lesson 2.

Lesson 2: Don't be clever. Have I told you how bad my memory is? I'm sure that past-me was very pleased with himself about a clever bit of code, but present-me looks at that code and has no idea what it does, what magical side-effects it has, or what possessed past-me to write such a thing. So present-me is just going to assume that future-me is not that bright, and write it the simple, understandable way.

Lesson 3: Write more tests. "This is [so simple|too close to the hardware|just a temporary hack], so it's really not worth the bother to write a test." I couldn't possibly count the number of times past-me has stuck me with this nonsense. Just write the test. Your code is never as correct as you think it is, and there's always some hidden dependency on another component (that will eventually change and break your code). Just the fact that a test exists will also encourage the next person to touch the code to extend the test when they extend the code, which is probably reason enough by itself. Present-me looks at the once-simple thing that is now all grown up and wishes so hard that past-me wasn't so naïve.