While on a recent train journey to Mumbai, as some of my fellow travellers absent-mindedly threw garbage out from the train window, I struck a light-hearted conversation with them just to understand why even after so many awareness campaigns and so much stress being given on having clean surroundings, it somehow fell on deaf ears. And while listening to their “defense”, it just struck me that the psychology or mindset behind littering the environment is almost the same as that when we write code which is not considered “clean”.

1. The area / code is already very messy, why bother?

If there is already some garbage lying around on the streets or the railway tracks, people have the tendency to think that since this particular area is already dirty and no one is bothering to clean it up, adding to the trash is not a problem.

Similarly, some piece of code which does not have a good design or has duplication gives us the tendency to feel that since its already messed up we should not bother much and its OK to write substandard code. This is also known as the “Broken Window theory” ( Ref : The Pragmatic Programmer ). One broken window in a building which is not repaired until some time, makes it inhabitants feel that no one really cares about it, which results in another broken window, littering, graffiti and in a short time, the clean building turns into an abandoned mess.

Don’t leave broken windows. Fix each one as soon as it is discovered. Don’t leave garbage lying around for very long. Clean it or get it cleaned immediately.

2. Someone else will clean it

Another psychology that people have is that the sweeper is getting paid to clean it up, so it is OK if I litter, the sweeper will do their job.

Likewise, many a times we end up with a “tech debt monkey” in our teams who are the only people fixing these technical debts and we don’t think twice before making an entry into the “tech debt” sheet and leaving it to the “experts”.

3. Really? It’s just one paper / line of code!

“It’s just a small wrapper, throwing it outside the window does not mean littering”.

Similarly, “it’s just these 2 lines of code which are messy, the rest is good” ; this mindset is the start of the rot and slowly it spreads.

4. Laziness

“The trash can is too far away, I am not going to go all the way to throw it”.

“This might not be the best way to code this problem, but the right way might take a lot more effort and time, so for now lets go ahead with the shorter solution and make it better sometime later”.

5. People are starving in India! What do you care about littering?

We feel there are bigger problems in life to solve than caring about our surroundings and that seems to be the most nonsensical reason to litter.

Likewise, “this needs go to production” or “I need to get this story done today” are excuses we make which ultimately hit us in the long run.

I have been a culprit of littering a few times, but just being aware of its consequences has made me think twice and prevented me from throwing waste in a public area and keep my code clean as much as possible.

So, finally let’s strive to keep our environment as clean as possible..and of course, our code too!