In PLC projects, many often say, "The more comments, the better the program!" This statement seems to make sense, after all, clear comments can help engineers understand the logic of the code more easily. However, is this really the case? Does the number of comments really determine the quality of the program?
During the process of program development, we often encounter a phenomenon where some engineers use comments as an outlet for expressing emotions, even adding some "special language." This raises an interesting question: Do comments with emotional language, or even profanity, have any impact on program quality?
"Temperamental" Foreign PLC Comments
Some time ago, I saw an article on a social media platform that actually studied this phenomenon. A German automation engineer specifically studied this. He collected 100 PLC projects with profanity and 200 PLC projects without profanity, and analyzed their adherence to programming standards through software, scoring each project individually.
Then, using the Central Limit Theorem in statistics, after a series of complex calculations, he came to a surprising conclusion: The quality of PLC programs with profanity was significantly higher than those without!
Can profanity improve program quality?
Hearing this conclusion, you might be a bit surprised. The engineer explained that profanity represents the emotional venting of PLC engineers when facing complex logic. When writing PLC programs, the complexity of logical control often drives people crazy. Venting a few profanities in time can effectively relieve stress, allowing engineers to focus more when coding, thereby improving the quality of the program.
This seems to make sense, but don't get the wrong idea that as long as you write more profanity in the code comments, the program quality will automatically improve. That would be a misunderstanding! In fact, the real key lies in the release of emotions and the improvement of focus, and profanity is just one of the ways some engineers choose.
China's Engineers' "Subtle Expression"
Unlike foreigners who are straightforward, China's PLC engineers generally do not "show emotions" in program comments. Comments, if possible, are omitted, and sometimes not a single line of comments can be found. This "subtle expression" may seem to make the project look neat and orderly on the surface, but it increases the difficulty of later maintenance. After all, the maintenance of the program is usually not done by the original developer, and code without comments is like groping in the dark.
Some may say, "No comments? I understand my own program, that's enough!" But the problem is, when your code is handed over to other colleagues or external teams, a project lacking comments is like a hidden pit. Especially when the program is complex, without comments it is equivalent to having no map, and subsequent engineers may spend several times the amount of time interpreting your logic.
The Art of PLC Comments
So, how should comments be added correctly? First, the more comments, the better is not always true. Excessive comments often lead to redundancy in reading, making the code messy. Ideal comments should be concise and to the point, helping the next person reading the code to quickly understand each section of logic.
Secondly, the content of the comments is also crucial. Don't just mechanically explain what the code does, but more importantly, explain why it is done that way. For example, a section of PLC logic is to cope with specific process requirements, or it is a special processing logic for a complex device. Such comments can not only help others understand your thinking but also allow you to quickly clarify the logic when reviewing it later.
In actual projects, if you see a comment with "emotional" language, or even profanity, you should be extra careful. Such comments often mean that the engineer has stumbled over a complex logic or problem, and if not careful, you may step on this "hidden bomb." So, when encountering such comments, it is best not to easily touch that section of code unless you fully understand its meaning and the logic behind it.
Comments are indeed a part of the quality of PLC programs, but they are not the decisive factor. Reasonable comments can improve the maintainability and readability of the code, but the number of comments does not represent the quality of the program. The key lies in the quality of the comments - they should help engineers understand the logic of the code, especially when facing complex projects.
Next time you write a PLC program, don't forget to take some time to write clear and useful comments, which may save a lot of trouble for subsequent maintenance. As for profanity? It's better to remain professional in the code.