6 tips to clean up your code

Matt E.
3 min readFeb 17, 2021

Writing clean code is an important part of being a good developer. Like a good book or newspaper, your code must be easily readable and understandable.

The goal is to keep to a minimum the cognitive effort required to iterate on your code.

Don’t hesitate to spend time testing stuff and rewriting it.

The clearer your code is, the fewer bugs it will hide, and the less time it will take for other developers to understand it.

Picture by Roman Synkevych

If it feels like you don’t have the time to focus on writing clean code, think about the time you will take away from the future team trying to understand the mess you left behind.

1. Use meaningful names

The names of your variables, functions … are supposed to give explicit and up-to-date information.

It should be obvious what they refer to, don’t be afraid to use a long name when it’s needed.

Single-letters names are only acceptable as loop counters.

They should not be deceptive, for example, if contactList is not a list, it might be confusing.

2. Use pronounceable names

You must be able to think and talk about your code, avoid complex acronyms or inside jokes.

Your names must be pronounceable and rememberable.

The human brain is used to play with words, don’t overcomplicate things.

3. Don’t mix up concepts

For each concept of your code, choose one word to express it and stick with it.

If you’re building a game and you refer to your users sometimes as user, sometimes as player, one might think you have two different entities with distinct roles.

Don’t reuse the same word to express a different concept either as it will be confusing.

4. Function must do ONE thing

Functions are small blocs that help you express yourself, don’t fill them with a lot of interlaced concepts.

Functions should do only one thing, they should do it well, they should do it only. (Robert…

Matt E.

Software engineer at Achiev & Jounco. Passionate about programming and entrepreneurship