6 Simple Habits to Adopt for Writing Cleaner, Readable Code

Jeffrey Bakker
The Startup
Published in
9 min readFeb 23, 2020

--

Any substantial codebase that has even a bit of age will have its dark and ugly corners, that’s a given. Not everything can be done perfectly and more often than we’d like, situations can push us into writing code we’re not proud of. Sometimes we have to learn on-the-fly and haven’t anybody in-house who is familiar with something outside of our core competencies. Over time, this will start to show in both code readability and in its maintenance.

There are simple habits you can adopt / monitor / abandon which have the potential to make life easier for you and your colleagues. This article is meant to be agnostic to any platform or programming language.

1. Copy and paste, or copy pasta

While undoubtedly copy and pasting can save time and prevent typos, it also has the potential to do just the opposite of both, especially if you’re not the author, and even more so if it’s untested code lifted from the web.

Aside from moving code, copy and pasting whole blocks of code should be used sparingly, or at least with vigilance and caution. If you’re copying from the current codebase, one would hope that you’re not duplicating work when you should be refactoring.

--

--