Readability of javascript codes

7

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

The longer you spend, the lower the readability of your code, and that's a sign that it needs readability improvements. An unreadable code today may be your loss of productivity in the future. What you do today, with complete understanding, in about 2 years when you need to do maintenance, may be unreadable even to yourself, and this will cause you to spend precious time trying to understand what you have written yourself.

  

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

It is not desirable for answers to this question to be based on opinions, but rather on facts, references or specific experience.

    
asked by anonymous 19.06.2017 / 12:42

2 answers

7

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

My gospel is called Clean Code - Agile Software's Practical Skills , and was written by St. Robert Martin (from the original English, Robert C. Martin). Following are two engravings which are the codification we received from the doctrine.

The canonical metrics for measuring good code:

Andthepathoftruthandjusticetowritinggoodcode:

Everything else is just different orthodox interpretations of the truth.

    
19.06.2017 / 13:46
1

I had a hard time understanding the image posted by our friend Renan . After a long time typing every part in Google Translate, I thought the idea was to post the image with the excerpts in Portuguese to facilitate the understanding of it by the community that does not understand English like me.

The whole rest is different alone orthodox interpretations of the truth:)

    
19.06.2017 / 22:04
Which is safer: session or cookie? [duplicate] ___ ___ erkimt I extend an abstract class or concrete? ______ qstntxt ___

When I need to extend a class, following the concept of Object Orientation, should I extend my code from an abstract or non-abstract class? What is the best practice to join?

    
______ azszpr89237 ___

There is no better option, you extend the class you need to extend. Whether it is abstract or not, it makes no difference to its code other than the fact that an abstract will possibly have unimplemented methods and its new class will have the obligation to create an implementation for all abstract methods contained in the class. optional).

If you want to know if it's better to create an abstract class or not, then it depends on what you want. An abstract class can not be instantiated. It is designed to be used as a template for other classes. Non-abstract can be used as models but can also be instantiated directly. You just make it an abstract class if you want to ban its instantiation (which is bound, if it is incomplete).

Of course, if the class has methods without implementation, they act as contracts for the derived classes to follow, that is, they function as if it were an interface, then the class must necessarily be abstract. Unable to instantiate classes with methods without implementation.

For example. If you have a class %code% and the derivatives of it %code% and %code% . Probably you do not need and maybe can not instantiate only the %code% . It is probably incomplete. You just created it to support the two (who knows other) derivatives I mentioned. It is almost an interface, but probably has variables and some methods with implementation. So %code% should probably be abstract.

Remembering that you can only inherit from a class. Abstract or not. Interface can several.

    
___