top of page
Writer's pictureAshley Kelly

Why I Always Write Readable Code: The Benefits



As a self-proclaimed "over communicator", I tend to err on the side of adding too many comments, variable names, and spacing when writing code. While this may seem excessive to some, I find that it helps me better understand my own code. Not to mention, it makes the code more readable for myself and other developers who may need to review it.


In this article, I'm not going to tell you why YOU should communicate more in your code. Instead, I'm going to tell you the benefits that I have found in writing readable code myself.


There are several ways to make your code more readable. First, use clear and concise variable names. This will help you (and other developers) understand what the variable is being used for. Second, add comments to explain what your code is doing. This is especially helpful for complex code chunks. Finally, format your code properly. Use spacing and indentation to make your code easy to scan and understand.


It helps me remember exactly what I was working on after coming back from a break.

Have you ever been working on a project and you have to stop or take a break for any reason? Maybe you got called into a meeting, or you a colleague asks a question, or you're working from home and something there needs your attention. For whatever reason, you had to stop, and then you come back to your computer...to finish...whatever it is you were working on before. What was the problem or the solution again??? Lol! Writing well documented and readable code helps tremendously with this. All you need to do is READ what you were doing before, and it all clicks back. You're able to restart your work quicker because you can actually recall what you were doing a lot easier when your code is readable.


I am able to brainstorm new ideas and debug easier when my code is sensible and easy to read.

When my code is written out in a way that almost feels like "steps" or an algorithmic guide, then I am able to figure out what my next "step" should actually be. This is especially helpful when I get stuck and don't know what I should do next or if I am trying to make my code more efficient. For me, it is easier to brainstorm new ideas if all of the previous steps are well established. Writing readable code means that I don't have to use the extra brain power to decipher what I have already done while also trying to build on those same steps.


Getting help is easier and more efficient when variables are easily identifiable and comments are detailed throughout the project.

This benefit is kind of self explanatory. If it is easy to see what you've done and where your problem areas are, then it is easier for someone else to figure out how to help you. Also, if you're a junior developer, readable code makes it easier for you to explain what you have done and how you got stuck in a way that is more impressive than someone who is sort of stumbling through an explanation of their work. Readable code may also help you help yourself. Reading back over clear and concise code to figure out your next steps may jog your creativity or remind you of a way that you solved the same problem before.


I can be sure that I am solving the problem that i started with if I can see the steps for solving easily in my code.

We all know the type. You know, the developer who keeps bringing up "issues" that may arise when they start a project. More often than not, we all have an end goal for what our code needs to achieve. (I may write another blog post about why having an end goal is important.) When your code is readable, then it should also be understandable, and show that the steps that you are taking lead directly to solving the problem that you were given. It is a lot easier to see that you have veered away from solving the original problem when you are writing consistently readable code.


Collaboration is easier when colleagues are able to quickly understand what they are seeing.

This benefit is related to the benefit of being able to get help easier when you write readable code. The code should be readable to you, but it should also be readable by others. Many of us work on projects with other developers where they may need to make updates to a file that we were once working on. We should not be silos of information for that project or any singular file. The best way to do that is to document and write readable code. It helps junior developers learn, and it helps new developers on the team contribute to the project quicker. If you are working with someone who is not a developer, then it helps them follow along when you are explaining or presenting your work.


These are just a few thoughts on then benefits of writing readable code. Comment below if you have more thoughts or benefits that you want to share.

Comments


bottom of page