Answer the question
In order to leave comments, you need to log in
How to stop commenting on everything?
When I first started coding (~2 years ago), I didn't comment at all. Working files with code were written very quickly, one might say they were stamped. But it was impossible to understand them without half a liter, because no one will read 500 lines of solid characters on a sober head... The matter was further complicated by the fact that I learned programming on my own, so I did not know the generally accepted standards and principles of good manners in code.
When it came to some changes in the code, I had to read that same 500-line treatise for a long time. Of course, I quickly realized that such code was not worth writing and began to add spaces and comments.
Gradually, my code evolved into something more or less pleasing to the eye. There were still few comments, and many of the few were out of place, but the code definitely got better.
So I gradually added comments until I hit the other extreme - there were too many comments. I am at this extreme now. At some point, I began to catch myself thinking that 20% of the time I write code, and the remaining 80% I think about and write comments. It even goes to the following extremes:
// Переменная для хранения информации о возможности клика по кнопке «Зарегистрироваться»
// true — клик разрешён, false — клик запрещён
var can_click_su = true;
Answer the question
In order to leave comments, you need to log in
Write code that is self-documenting.
Give meaningful names to variables and functions, albeit longer, but more readable.
Read about architecture, patterns.
I recommend "Clean Code" by R. Martin. There this topic comes up.
Do not be afraid of long names of variables and methods, if the code explains itself, then comments are not needed.
If I do it for myself, I made it a rule to explain to myself in the future what is happening here in principle.
I also comment on non-trivial solutions. Moreover, in this case it is very detailed, sometimes with http links to the description of this or that algorithm.
In general, if you follow these principles and you get a lot of comments, then this is a sure sign that the method or even the whole class needs to be rewritten again.
familiar. I also once scribbled green screens on VB6 somehow
... you need to take it and stop commenting on everything.
When I switched to languages that allowed long variable names, now I'm Writing Awesome Long Variables That I Understand.
in fact, in this case, with normal meaningful names of variables, functions, classes, only a very small part of the code requires commenting - when you need to explain why it is so here (often, by the way, this is a sign of a crutch)
// Variable for storing information about the possibility of clicking on the "Register" button
// true — click is allowed, false — click is prohibited
var can_click_su = true;
var can_click_register_button = true;
Something tells me that your problem is not technical, rather it looks like some kind of obsessive desire to “explain everything” (you write about it yourself). Try to find a psychotherapist. Just do not confuse with a psychiatrist - a psychiatrist treats diseases (with pills), and a psychotherapist helps to understand the reasons for his desires / actions, to begin to relate to what is happening in life differently, etc. - quite healthy people who want to change something in themselves go to them. I'm not kidding - my wife is a psychotherapist.
In fact, this is a philosophical question, but I would recommend drinking a course of vitamins, especially B and drinking Nootropil with Glycine.
Month 3.
And then everything will return to normal.
The latter is especially useful for study and mental stress, but when there are not enough B vitamins, there is an ache in the bones.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question