DEV Community

Cover image for Importance of Documenting
Naveen.S
Naveen.S

Posted on

Importance of Documenting

We want to show you very good practice and that is to document our code, reduce those moments when we don't know what a part of our code does or how it works because we have a long time without reviewing it.

πŸ”₯ The idea of ​​the documentation is to leave comments in our code to recognize what it does, what it needs to run and what the result is. In this way, if we have to make a refactor (review and modify it) we can do it very easily.

There is JsDoc which is a JavaScript code documentation API that makes documentation very easy for us and generates a standard that is easy to follow but it doesn't matter if we use JsDOC to document or any other strategy, the important thing is to put it into practice.

In the example you can see that there are several ways to document, the first is a simple comment that explains what the function we created works for, the second gives us a little more context by adding extra information about what the function does, in this case, is a constructor and the third one we have the parameters and the type of variable that the function needs.

So I ask you, have you ever documented? Let me know in the comments.
.

Top comments (1)

Collapse
 
pentacular profile image
pentacular

The idea of ​​the documentation is to leave comments in our code to recognize what it does, what it needs to run and what the result is. In this way, if we have to make a refactor (review and modify it) we can do it very easily.

Personally, I think this is entirely incorrect.

The code shows what it does, what it needs to run, and what the results are.

What the code does not show is why it does, needs, and produces what it does.

Useful documentation fills this gap.

On the other hand, poor documentation repeats the what and the how, making refactoring more expensive.

Let us focus on the hidden why when we write.