Dear future me… you’re so welcome!
Recently there has been a discussion on code and performance audit in linkedin. It is hilarious! If you can read Lithuanian I encourage you to do so, there are tons of golden quotes. They compare software development with moving bricks and producing chairs. (To be clear — I don’t call CRUD software development. As well as doing same thing over and over again. For me, software development is nothing else but problem solving with the right tools. If you’re repeating yourself non stop, that might be a problem. Solving that would be software development. Copy pasting code however is not.)
One particular quote sounds like this:
//Dear future me, you cannot imagine how sorry I am
Well, it’s a comment somewhere in the legacy code.
What scares me that this is accepted as “funny but true”. No I don’t mean that you should code perfect from the first time. Your views on design might change with experience. You might learn something new about your language. You might solve it with one code line instead of one hundred. You might think that the code smell is so intense that it gives you headache. But as long as you have that particular smelly part of code covered with tests you will thank your past self no matter how much the code sucks. Trust me on that.
I work with legacy system and I see copy-paste code everywhere. I see bad design decisions and endless methods. Single files of 5000 code lines that don’t seem to differ too much. There are singletons almost in every step. Nothing is dependent on abstractions and code is incredibly highly coupled.
But I can say this: if I take some time to put a piece of code under tests, even if it might make it uglier, since that moment, I thank and thank myself non stop. Even if the future me is only one week away, I know that guy will be happy as fuck when he finds that part of code under tests. Sometimes the guy is not even future me, it is present me and he is happy to work with that ugly piece of code that he didn’t even write!
I learn constantly and of course time to time I will come across some code that would make me think “What was I thinking?!”. But as long as it is well tested I will not blame that poor stupid old me.