I see a point in many places that says, “Please stop commenting, because only bad code needs comments.” This is a very clever point of view, which reminds me of mencius’ saying, “Yang is for me, no prince is also; Universal love is fatherless. Fatherless and kingless, they are animals.”

Always scold others is “beast”, I always feel a little wrong, this is not in line with Mencius noble spirit ah. If someone asks him to add comments to his code, it seems to be an insult to him: “My code is so elegant, can’t you understand it? Comments are redundant!”

I have to admit that every programmer should strive for “elegance” and make their code easier to read and understand — not just for machines, but for our fellow programmers as well. But not every programmer can write “high standard” code in the beginning, just as not all Kings and common people can understand Mencius’ concept of governing a country.

The period when I first returned to Luoyang was very painful. Because I just took over a project that someone else left behind, on bulk futures trading. The back-end code is written in Java, but it has a lot of bugs in it. It often fails to settle funds and even runs out of memory. The only way to solve these problems is to understand the code thoroughly.

Otherwise, there’s no way to start. It’s like when you go on a road trip with your friend to a place far, far away. Your friend is tired and needs a rest. If you don’t pass the driving test, you will be blind and have to pull over to the side of the road.

I was blind. In all honesty, the code left by a former colleague is brilliant, and I wouldn’t be able to write it if I wrote it. After all, commodity trading itself is a bit difficult, requiring bidding and matching, a business that is more complicated to understand than equities.

Stocks gain when they go up, lose when they go down. Futures are different, buy up can earn, buy down can also earn. The complexity of the business is secondary to the fact that comments in the code are as rare as hair on James Gosling’s head.

Besides, you know the Basic English skills of domestic programmers, variables, methods, classes, interfaces, enumerations can not achieve the real meaning of the name as it means. Plus, some methods have as many as three or four hundred lines, and you just want to punch yourself from start to finish.

No way, my solution is to read a line of comment, after all, comments are easier to understand than code. Just like when we call an UNFAMILIAR API, as long as the documentation of the code says what it does, we can use it, dare to use it, as long as we don’t understand the implementation details.

It took me almost two months (very long, very painful) to get the core code of the project down to the ground. Once you figure it out, you’ll be able to fix bugs that you couldn’t fix before.

That’s part of the reason WHY I advocate reading source code, in addition to learning, reading source code is a killer for solving bugs. To read the source code, comments are essential. Do not believe, you look at the Java source code, every variable, every method, every class, annotation is very detailed, detailed to you feel tired for the source code author.

Java source code authors are, in my opinion, the best programmers in the world, and even they write comments. Those who say “please stop writing comments” are going to slap their faces until they are full of blood.

Don’t doubt yourself, writing comments does not prove that your code is bad. I believe that you have bought electronic products, such as mouse, keyboard, earphone, mobile phone and so on. In addition to the product itself, the instruction manual is indispensable in the package of all products. I just asked, “If there’s no manual, can we still use it?”

Writing comments is not our fault; software is inherently complex. Especially for those of us whose English is not our primary language, annotations are especially important. I’m probably one of those people with poor memory. Every ten days and a half months, WHEN I look back at the code I typed myself, I sometimes feel like I’m looking at a stranger: “Did I write this code? Why a little noodles?”

Most people write code that needs to be updated and refactored, right? Whether it’s the upgrade of the language itself, or the growth of our own capabilities. If in the upgrade of the reconstruction, without the help of these notes, really a little climb mount Tai feeling, tired ah, pro.

Furthermore, Daniel can’t guarantee that his code is free of problems, right? But comments are not deceptive, and their meaning is clear. You may forget what the code is for, but I guarantee you, comments will refresh your memory.

Writing good, meaningful comments is hard, just like writing code. Code and comments go hand in hand in the pursuit of excellence. Comments make your code easier to read, and code makes your comments more logical.

Even if your code is elegant enough to not need comments, that’s only at your level. The same cannot be said for your colleagues, the people responsible for your code later on. There aren’t a lot of heroes who think alike, and your code that looks elegant may look like crap to someone else, while your comments may help someone else “see the light” of the code. Be good with your comments. It’s good for you and everyone else.

In addition, I would like to say that comments are like a blueprint or a summary of the code. Before you start writing code, it’s important to have a clear idea of what you’re going to implement and how you’re going to implement it, and writing this down as comments will definitely help you write more elegant code. After you’ve written your code, you can summarize it with comments that allow you to refine your code and perhaps even come up with a better solution.

I also saw a bull swear that writing notes is like throwing a life buoy to someone who can’t swim and he will never learn to swim. At first glance, that makes a lot of sense, right? In their opinion, the best way to make a new person grow quickly is to throw uncommented code at him.

That’s bullshit. I’m afraid the new guy gave up without getting started? I’m thirty-one. No, I’m eighteen. I can’t swim. Don’t listen to those big boys. I don’t believe him. He didn’t write his own notes.

In short, comments don’t prevent you from writing elegant and concise code; they’re just an inherent part of your program.

If you think this article is helpful to you, please search wechat “Silent King ii” for the first time to read, reply to “resume” more than 3000 people have downloaded the quality of the resume template, from now on your resume will never be empty.

GitHub, portal ~, GitHub, portal ~, GitHub, Portal ~

I am the Silent King 2, a programmer with good looks but mediocre talent. Attention can improve learning efficiency, don’t forget three even ah, like, collect, message, I don’t pick, hee hee.