Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 2, 2022 12:52 am GMT

Please, comment your code...

Why i should comment my code ?

If you're actually code in Java, JavaScript, Python, PHP. You're probably hear about technical documentation and some things like :

And if you had not heard anything about "how to comment your code". So you was, you are or you will be confront to THE question :

"What this code do ???"

And you know how it's painful when something doesn't work and you can't understand WHY !

Rage developer

When you use an external program, your reflex is to read documentation about this program to understand how to use this.

When you comment your code, the objectives is the same. You'll write some details for you in the future or for the people who use or improve this code.

Objectives

The objectives is multiple, just think about you in 2 years in this code. You'll be happy to see somes comments who explain what is this weird classes you added before .

Now, if you don't code alone. Think about you're associate will read and use your code.

And PLEASE, think about all people who use your code in the future if you're make an open source program.

I think you understand now, when you comment your code you actually :

  1. You saves time for you, and for other peoples
  2. Describe, and have a readable code
  3. Your code will be accessible

When i should comment ?

It's recommended to comment your class, you're function and use inline documentation when is necessary. I think it's the minimal requirement for a readable code.

A code has commented, is a readable code. BUT, use comment whith thriftiness.

Of course, if you're function is named sum for example, and take two arguments. It will be really simple to know what the function do.
Personaly I think you should comment for function when the function is over 10 lines, and it's required for classes.

And please remember, a developer does not only code.

A developer maintain, debug, keep an eye on evolution, document, and think how to resolve problems.
So please, comment your code and make happy the "you" of tomorrow and all people who read your code. And you'll make a step to become a programming god .

God developer

Tell me if you have any suggestions, or remarks and of course if this article was interesting.
There is so much to say about this, feel free to express your point of view, so don't hesitate.


Original Link: https://dev.to/tykok/please-comment-your-code-4jj0

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To