Three reasons why comment your code is a very good practice
I remember when I was 19 and I was learning to program. My teacher said many times:
comment your code, is very important in this process.
and I just thought a lot of times:
crap, again 50 lines of comments to write 10 lines of code. It sucks.
- Now, 10 years later I understand the reasons and today I wanna share it with you.
Comment your code will help you and your team to know what the hell are you doing
Seriously man, no one knows what the fæçk is happening in your mind. So that is the most important reason to comment your code. Let your team understand you and your mental processes.
If you don’t trust me think about that. One day you are in you beautiful development place and suddenly you listen your name followed by a sentence like that:
Can you help me with this piece of code that you made?
Probably your partner needs refactor your code to add a new feature, or she/he is making a code review, anyway, that sounds easy, however when this guy starts to read the code don’t understand your tricky way of solve a problem.
That is the first reason to comment your code.
Not all developers solve the problems in the same way. Explain your team how you did it.
Comment your code will help you to remember what did you do the last summer
The last summer or the last day, if you are a guy like me, probably you won’t know what would you have for diner last night, and exactly that happens with your code, you write a few lines and one week/month/year later you don’t remember why you did something.
If you don’t trust me just think about the first reason to comment your code (Not all developers solve the problems in the same way) and think that every day you grow up and change as a developer, as a person and in every aspect of your life, therefore you not are the same person that wrote these lines of code a week ago, you’re a different developer and probably you will say:
I was so high when I wrote this…
If you have said something like that any time in your life now you have a good reason to comment your code.
Every day you have different outlooks on life. therefore you aren’t the same person that wrote these lines of code some time ago.
Comment your code will reaffirm all your knowledge about something
When I started to learn by myself I wrote POCs in my free time to test new technologies or frameworks. However, many times the knowledge was limited to the famous copy and paste, causing a fast lose of this because the learned things lacked of sense.
In many cases when the developers grow up they start to take time to learn (understand deeply a new concept) and hold back learned things. One of tools to do that is the documentation because it force the developer to understand what are she/he doing, also probably show her/him a missing concept that can be polished by the way.
Documentation process force the developer to understand what are she/he doing, also probably show her/him a missing concept that can be polished by the way.
OK, these are the reasons to document your code, I hope you like the post and think for a moment about it.
If you like it share it please.