Readability of javascript codes

Asked

Viewed 351 times

7

When writing a code you must do it so that the time required for your understanding is minimal. This is the most important metric to have a readable code and is the foundation of the fundamental legibility theorem.

The more time you spend, the less readable your code is, and that’s a sign that it needs readability improvements. An illegible code today may be your loss of productivity in the future. What you do today, with total understanding, in a couple of years when you need to do a maintenance, can be unreadable even for yourself, and this will make you spend valuable time trying to understand what you wrote yourself.

So what would be the interesting ways to apply this theorem and measure the readability level of the code?

Is not desirable that the answers to this question are based on opinions but rather on facts, references or specific experience.

  • 2

    I must understand that the negative vote says that there is no need to worry about legibility, any written crap anyway is good, as long as it works

  • 1

    I did not vote against, but I suppose whoever it was simply understood that the question is too broad. In fact, "legibility" is a nebulous concept, and a good style in one language can be a bad style in another. Incidentally, it can vary from project to project. And the line separating "opinions" from "specific experience" is tenuous...

  • I wrote an article a few weeks ago for a blog where I describe some practices for leaving a self-documented code. Here is the link: http://www.sigaonerd.com/2017/06/vba-artigo-034-left_codigo.html I hope the article will help answer your question. The best thing is to read the book I put as a reference at the end of the article.

  • 1

    The question goes for any language and the answer will be the same. Now, to avoid shooting yourself in the foot with Javascript, I recommend the book Javascript: the good Parts.

2 answers

7


There is a book that is something like the Holy Bible on this subject. I have already taken him for sacrosanct truth and I see any deviation from his teachings as heresy.

My gospel is called Clean Code - Agile Software Hands-On Skills, and was written by Saint Robert Martin (from the English original, Robert C. Martin). Here are two engravings that are the codification that we receive from the doctrine.

The canonical metric for measuring good code:

WTF's por minuto

And the way of truth and justice to the writing of good code:

inserir a descrição da imagem aqui

Everything else is just different more or less orthodox interpretations of the truth.

1

I had a little trouble understanding the image posted by our friend Renan. After a long time typing each excerpt in Google Translator, I thought of posting the image here with the excerpts in Portuguese to facilitate the understanding of the same by the community who does not understand English as I do.

Good Code

The Whole Rest is Different alone Interpretations more or Less orthodox of the Truth :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.