Code Documenting Part 2

In this article, I will to say about Comments in code.


My last article was about some good practices for writing your code. Now we let’s go to study comments in the code. We also to see the solution for problem that was presented in the last article.

So Let’s go.


This article is a complement of the previous article.

I would like make clear that good code do not need many comments, because your variable’s and method’s names are auto explicative.


Good, firstly, exist two forms of use comments in code, they are:
First type, you need write two / and after this, you write your code, this comment stay only a line, for example:

//Your comment


Second type, you need write /* for open the comment, and */ for close the comment, all text that written inside the block, will stay as comment.

 /*
Your comment
*/


Now we let’s go to solve our problem that last article.
We have this method with this parameter:

public void Reduce_Player_Life(int Damage_For_Reduce)

How to document this?
You only need write a comment informing where it is used, for example:

//This method is called in class named Enemy, on method, OnCollisionEnter2D
public void Reduce_Player_Life(int Damage_For_Reduce)

Follow-me in Instagram for stay knowing when I create new posts @mauro_developer
You can also leave your feedback, and your suggestion, I will to read all, and I will to answer for you.