Better Programming

Advice for programmers.

Follow publication

“Do It Right, Do It With Pride!” — Advice for Developers

Write code that’s easier to comprehend

Marco Luizinho
Better Programming
Published in
4 min readAug 1, 2022
Photo by Do Nhu on Unsplash

Every day we interact with people, at work, at home, and even virtually… We often take it for granted, how the little decisions we make and actions we take, can influence, impact, and affect the people we deal with. Often, with just a little awareness and intent, we can make others’ lives easier and more pleasant, with very little effort.

Take an electrician for example. For the lights and plugs in your house to work, the only thing that is necessary for them to function correctly is that they are connected correctly (obviously they also need an energy source like… dare I say… Eskom?). The wires and connections don’t need to be neatly separated, labeled, or organized at all.

The electrician example is very relatable to code… The wires, connections and other electrical components throughout a building are “hidden” to most mere mortals, as is the code that so many of us write.

These details are abstracted away from people that don’t need or want to know anything about them, however, just because something isn’t visible, or tangible to all, doesn’t mean we shouldn’t do it properly as if it were indeed on showcase.

The ”out of sight, out of mind” idiom sadly comes into play here… and as a result, these electrical configurations can, and often do resemble a form of spaghetti— not the mouth-watering kind, but rather the eye-watering kind. Just because these details are abstracted away from everyday folk, doesn’t mean that another person or your future self won’t need to work on it again.

What about when something goes wrong and needs fixing or when the initial implementation requires extending or enhancing? Someone’s got to attend to it… right? Whether it be the original “Italian wire chef” or the next unlucky chap who must make sense of the mess… The additional time required and frustration it usually includes are completely unnecessary.

The electrician example is a simple story of creating something that is not maintainable nor scalable (or not easily at least). Not surprisingly, this is where the term “Spaghetti Code” originates — where not enough forethought went into the planning and design phase of the original implementation, or perhaps it was just written without much care or pride. The code was written to do something specific, and while it may just do that… How well does it do it? How well can it be maintained or enhanced in the future?

As most developers have encountered this code conundrum before, it’s likely to add scope creep or delay a deliverable. And if that’s not enough, it is a breeding ground for bugs.

Don’t get me wrong, there is a time and place to hack a proof of concept or one-time solution together and then be gone with it once it has served its purpose, but these such cases are the exceptions, not the norm…

From a decade of experience in software, I offer this advice: Every time you find yourself creating a “one-off” throw-away solution (hacking something together), ask yourself: could I use this or a version of this in the future? Could I make this more generic to extend its potential use cases? Is any piece of this solution transferable or reusable? And if the answer is yes to any of those questions, then while the context is fresh in your mind, invest a couple of minutes (timebox it), go ahead and refactor it, add a readme, or even just comments if need be. Take some pride and make it easier to comprehend for when you or the next person needs to revisit it in the future.

I assure you as you start to do this, and it becomes your normal way of doing things, you will also feel more accomplished and prouder of the daily work you do, making your journey more enjoyable, even if some of your work is abstracted 5 layers deep or never sees the light of production… Just do it right, so you don’t have to redo it later.

If you manage to do this consistently, then, over time you will also build a portfolio (a library of solutions and tools) that you will inevitably come back to over your career… When you do find yourself or another person in search of something from your library, how would you like to find it? Would you like to be rummaging through some old pasta? Or would you prefer to be met with a little work of art, with sprinkles of magic that you added the first time around… How would that make you feel?

Success is a journey, not a destination. The doing is often more important than the outcome. — Arthur Ashe

Sign up to discover human stories that deepen your understanding of the world.

Marco Luizinho
Marco Luizinho

Written by Marco Luizinho

Sofware Delivery Manager from JHB, South Africa, Father, Husband, Athlete, Growth Mindset.

No responses yet

Write a response