Be kind to your future self — code clean!

Atul Shukla
mickeysden
Published in
2 min readOct 26, 2018
“person touching brown horse head” by Sebastian Abbruzzese on Unsplash

There is a story (a true one) I like to tell developers I work with. When I was doing my masters (a long time in a…you get it), I had taken a course on distributed computing, and we had a class project to build a Symmetrically Initiated Threshold Based Distributed Scheduling Algorithm. At the time, it was largest code base I had ever written from scratch. It was developed in C. I did well, and was proud of myself to be able to write and execute a distributed application where each piece would be independent and interact with other pieces, and had a central controller (the bottleneck and the single point of failure! But hey, that was then, and this is now!).

About a year later, my then roommate was taking the same class, and one fine evening when we were both in the lab minding our own work, he asked me to look over a section of the code he was working on, saying he was stuck. As I tried to recall how I had solved the problem at hand, I decided to pull out my old code (just a bunch of files in a folder — no SVN, no Git!!). I walked through and found the section in question, and then was literally staring my code for 10 mins when I said, “What the hell did I do here”. There was module that was about 20 lines of code, which I said I could do in 2–3 lines!

The gist of the above story is two-fold —

  • With time we learn new ways to optimize how we write the same type of code, but more importantly,
  • Quite often we have to go back and read our own code

Developers usually complain when we inherit code from another developer, or when we use a third party framework and feel it is not setup the way we would want it to. We complain about the quality of code and the fact that what was the developer thinking! What we do not realize is that any developer can find potential issues with the way we code as well.

Unfortunately most of the times, its not that we are modifying someone else’s code, rather our own code. Sometimes code written years ago. And what we find are bad practices and no documentation from a younger self, who might as well be a different developer.

So, friends, developers, code countrymen, lend me your ears! Be kind to your future self, code clean!

--

--

Atul Shukla
mickeysden

Husband, Father, family man and Code Philosopher