The 3 L’s Towards Loving The Code We Hate
Filed Under Code, Personal Improvement, Quality Controls
We all do it.
File, Open. Scroll down, scroll down, pause. WTF!^$%@!. Scroll up, pause. Scroll down. “Wow……, dude you have to come look at this…”
Yeah, we have all been there, finding code that we love to hate. It’s sloppy, hard to read, and looks like a monkey with no fingers pounded it out. Code so ugly only it’s mother could love.
But really who can blame software developers for hating other developers code? A large part of software development is artistry and intellectual matter. I assume that literary authors have a difficult time truly enjoying other authors’ work because either they believe it is horrible or they deeply respect it but then have a sense of jealousy.
So what can we do to find enlightenment instead of anger in these moments of discovering rotten intellectual stew?
Laugh
It is very easy to get angry, but why? The damage is already done, so let’s do something constructive.
Pretend that you wrote the code 5 years ago. Hell, maybe you are looking at your own old code – oh the irony! Whether a co-worker, past employee, or you wrote the code – take a moment to chuckle at it. Chuckle at it’s complexity, chuckle at it’s comments, but most important chuckle at fact that you once were at this point too and that is why you are now wise enough to recognize a better way of doing things.
Learn
One of the largest life lessons I could ever learned was to take every single moment, reflect on it, and attempt to learn something new.
Although there may be a dozen better technical implementations, take the opportunity to speak to the original author and try and understand what they were thinking. In my career, the most enlightening moments have been listening to the innocence of interns.
Learning goes both ways, and be sure to also teach offenders why some code is smelly. Teach the wisdom, direct the plan, and help (or review) the execution.
Leave It Better
I don’t know who started the “Campground Rule” but Uncle Bob used it in his book Clean Code:
We should leave the code cleaner than we found it – Robert Martin
Identifying and laughing at bad code helps you accept it, but only fixing it helps you find new love in it.
4 Responses to “The 3 L’s Towards Loving The Code We Hate”
I’d have to say that “Leave it Better” becomes a mandate for my team if we’ve wasted time on trying to understand a big mess. Being a small group we really value our time and support one another by “taking out the garbage”.
[…] keep this article positive, but I just have to have a word on this one … as someone pointed out, everybody loves code they can hate, and this is my personal sleeping […]
Good advice. I will try to apply laughter as I start browsing the code when I start my new job on Monday.
Few week ago, I got to return in my own old code, that I have made just after college.
Looking at it, I start laughing hard. I’d wondering, how could I code this way.
That’s the fun part. My Todo now is to refactor / fix this old code..