How to improve the readability of your code?

Hi there, I been programming for over 1 year, and Im somewhere decent programmer, I just really struggle trying to write code that has good readability; for example trying to figure out a good name for a variable can take me a good while.

Is there know as fact that a good code isn’t always the one that can run 10% faster or take less memory, most of the times a good code is the one readable easily as the majority of projects are not lonely and more people will/should read your code.

The intention of this topic is give any tips or learning material that you can do for improving the readability of your code?

pd: Sorry for any typos or bad grammar (english isn’t main lenguage)

Hi @nomargomezc Welcome to the forum!
To what you are referring is commonly call “Clean Code”. I don’t know if you have heard the Say “Code as if a violent psychopath will read your code.”
Many people do not understand that, functionality is important, but you also have to make the code work without too many lines. Less as possible.
There are many ways of doing that, (begin by defining good and necessary variables, do not abuse of comments and so on).
I share with you a resource that could be of help.

Best wishes


Just make sure you don’t too strictly adhere to the ‘Clean Code’ orthodoxy. Clear is better than terse. Fewer characters is not always better and comments are not always bad.


My advice is 2 fold:

  1. Know your audience.
  2. Keep making it as obvious as possible.

Know your audience
Knowing who is going to read your code is important in the context of understanding who your writing for. Obviously the machine will be reading and executing code, but what about who is maintaining it over time? Its possible its just you, or someone else with an unknown set of skills, or someone you know. Thinking about your audience can help set expectations accordingly, and at least keep things consistent as you should have the same audience in mind.

Keep making it as obvious as possible.
I’ve heard many terms to describe code quality, like “elegant” or “clean” or “obvious”. However code quality isn’t a standard, its a process. You should continually strive to make your code obvious, and keep performing the process. The definition for “obvious” should change over time as you learn more patterns and be able to wield your language syntax better over time. With the end goal being making it “obvious to your audience” as much as possible and continually improving your code toward that goal.

1 Like

This helps thank you