Code Documenting Part 1
In this article, I will to say about Code Documenting.
So let’s go to start
Is very important that our code be good documented, because this create a facility for maintenance.
Now a question that probably is present in your brain is, how do to this?
Is exactly, that I will to say in this article, how to do a code with a good documenting, this is a Part 1, in next part I will to say about comments in code, and how to solve a problem that will to be presented in this article.
For to start, let’s to say about names.
Your classes, variables and methods, need have an auto-descriptive name. I will give examples separately:
Classes
Incorrect
public class Dmg: MonoBehaviour
What is DMG?
For you DMG can has a sense, but for others DMG can do not has sense, DMG is an acronym, the unique way for to discover is opening the class and read. This it costs time that sometimes you may not have.
Correct
public class User_Damage_System : MonoBehaviour
Now I will to say about correct example, here we have User_Damage_System, so with base in this, I know that this is a class responsible for damage in user.
Variables
Incorrect
public int value;
Again, I have the same question, what is value? What your function? What he receipt? You only to know when open the class and read the code.
Correct
public int _Player_Life;
Here We have a correct name Player_Life, we know that the reason for your existence is for receipt the Player’s life value, and we know also, that for increase or decrease the player life, we only need to change this value present in Player_Life.
Now I will to present our problem that will be solved in the next article.
Method
Incorrect
public void R_L_P(int value)
So, I already made the same question many times, and here is completely unnecessary to repeat the question. R_L_P, do not says nothing, and value do not says nothing, the unique way for to know that this method make, is reading the code.
Correct
public void Reduce_Player_Life(int Damage_For_Reduce)
This name is completely good, because, on method name you can to know, that method will to make, and the parameter says the reason for your own existence.
For last, here is our problem, Damage_For_Reduce is a parameter, and Reducle_Player_Life is a public method, so, here will my question, how to documenting this? Come from Damage_For_Reduce? How to documenting this?
This question will to be answered in next Article, Documenting Code Part 2, where I will make about Comments.
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.
Thank you for to read.
Sylvia
I like the valuable information you supply for your articles.
I will bookmark your blog and take a look at once
more here regularly. I am somewhat certain I will be
informed plenty of new stuff right right here! Best
of luck for the next!