2018/6/29
Some people agree that programmers should write comments for their code, while others do not. In my opinion, I completely accept that programmers should write comments. However, the comments should be written clearly and meaningfully.
I agree with the saying: "Good code is self-documented." Unfortunately, products developed several years ago may have bugs. How do you quickly retrieve memories, what were you thinking of at the time? Moreover, the code is never your own. Maybe you will leave the company for a better future or for other reasons. Writing reviews will let other people who maintain your code knows what you are thinking. For the reason that you never know if you think good code is the same as everyone else.
Therefore, good comments will make maintenance easier. So, the main question is "What are good comments?" I think there are two basic rules.
Meaningful
Provided that you have read previous coding style articles. You will know that a good name makes it easy for others to know what these variables are and what methods and functions are. Although short names are sometimes difficult to provide the actual work done by these methods. At this moment, it is helpful to write meaningful comments.
Helpful
This is a bit different from what meaningful. There are some codes that make you feel stupid and you want to modify it. However, after you have invested a few hours. You find that stupid code is actually the simplest and best solution. This means that someone did the same thing before. Why don't you write a comment to record how much time you spent on this stupid code. The next time you or someone else meets the same location. You will not choose to waste so much time.
Finally, I remind you that if you don't want someone to track your code through a browser, neither want that comments become useful information for hackers. Before you deploy your code to the Internet, compress and encode the code.
I agree with the saying: "Good code is self-documented." Unfortunately, products developed several years ago may have bugs. How do you quickly retrieve memories, what were you thinking of at the time? Moreover, the code is never your own. Maybe you will leave the company for a better future or for other reasons. Writing reviews will let other people who maintain your code knows what you are thinking. For the reason that you never know if you think good code is the same as everyone else.
Therefore, good comments will make maintenance easier. So, the main question is "What are good comments?" I think there are two basic rules.
Meaningful
Provided that you have read previous coding style articles. You will know that a good name makes it easy for others to know what these variables are and what methods and functions are. Although short names are sometimes difficult to provide the actual work done by these methods. At this moment, it is helpful to write meaningful comments.
Helpful
This is a bit different from what meaningful. There are some codes that make you feel stupid and you want to modify it. However, after you have invested a few hours. You find that stupid code is actually the simplest and best solution. This means that someone did the same thing before. Why don't you write a comment to record how much time you spent on this stupid code. The next time you or someone else meets the same location. You will not choose to waste so much time.
Finally, I remind you that if you don't want someone to track your code through a browser, neither want that comments become useful information for hackers. Before you deploy your code to the Internet, compress and encode the code.
Copyright © 2018 William Hsu All rights reserved.