+ 2
[Solved] How frequently do you have to revisit your own codes to understand just by your comments what you did?
Is it normal not understanding it at all at first sight if you've not paid attention to it since you wrote it? When you were a newbie, did you use to write introductory explanatory comments to summarize your approach, as well as the short inline comments? Would it be a waste of time to do that? Time that could be used for doing some other exercise? Or does it actually prove to be more useful for retaining the material learned? Thank you.
9 Respuestas
+ 1
Korkunç TheTerrible Like if you have a program such as below:
//This is the first variable that I want part of the equation
val a = 4
//This is the second variable that I want part of the equation
val b = 6
//I am going to add the two variables above and outprint the answer
println(a+b)
Like that's kinda overkill especially since the topic is quite basic, even for non-programmers.
Here's some of my own codebits where I add a lot of comments that focuses on the WHY because they were my first time really grasping the topics:
https://code.sololearn.com/cFB9l25qNTw1/?ref=app
https://code.sololearn.com/cN69Q819F5ss/?ref=app
+ 2
Korkunç TheTerrible
Exactly. Some things are hard definitions that after using so much (which you definitely will like variables, functions/methods, etc), there won't be a need to reference what those mean after a while.
But things where you need to understand the LOGIC behind what is happening that can't be so easily understood by just looking/variable names, it can be definitely important to comment some codes especially as a beginner.
And to be honest, as a beginner, it's better to over comment than to under comment, especially when you're earlier projects will be stepping stones you can reference back to when you for how an algorithm works or like what statements do like a 'do while' loop or something.
And remember that naming can also kinda be like commenting. Don't just use variable names with single letters. Use the name to clearly explain what is their use!
+ 1
* It's normal. ( for my knowledge)
* No, at begin, I don't know how to write (good) comments..! Some what better now.. 🙂
* No. Waste of time at all. It helps others to understand code, since every one has its own approach. Until you told, may others can't understood it.
It just like, Notes making. Is it not a format of your approach in academics..?
Anyways, It's always your priority first. Is it helps you? Follow it. Not,? Then find your own approach and fallow..
Hope it make sence..
+ 1
Jayakrishna🇮🇳 Thank you Jayakrishna.
So is it safe to say that:
As a newbie, I shouldn't mind the length of my comments. Those are not just codes but notes/studies.
It's only advised against if one's a professional, right?(I keep seeing people saying to keep comments short)
+ 1
Every single stinking day. GitHub is my savior cause otherwise, my computer would have way too many reference projects taking up space. 🤣
I still consider myself to be a newbie but I don't think you should ever really... Stop doing that. Remember that even though comments are ignored by the computer, doesn't mean they are irrelevant. Comments are codes for humans, especially for future you and also collaborators. I can't tell you how many times people asked for help and I ask them what they mean by a certain piece of code cause they have no comments and they don't know either.
And especially if you're working on big projects. What you coded a month ago, you're going to forget the purpose for if you don't comment properly. Just because you named your variables well, it doesn't mean they explain WHY the code is there. People tend to only comment what a code is doing, but there should be a why to explain it's purpose.
It is never waste of time to comment. Just make sure to also not overdo it.
+ 1
All the codes or work do here are just a practices. All these helps you in your future big projects. Think in that perspective.
Think I wrote a code, but seeing you not understood anything.. !
Next I added comments but still those lengthy..!
I added some what clear, and small as much as possible.. !
What are your responses, in these cases? Do you share it and what you expect as a reply..! Your answers are your question answer I think.
+ 1
Justice OK, so, if it's gonna be of help to you, but you know that others might not need it, you keep it concise without compromising understandability.
You don't go around explaining to yourself what a function does or what domain it operates on, however, just so you can pound it in your head, because you can look up for it as many times on the internet or so can anybody. Those are what keep being basic, even if your knowledge advances, if I'm getting it right.
Thank you for the codes by the way. They clarified things for me.
+ 1
Many thanks to you both. I was torn about it, and these pieces of advice are valuable to me.
----
I don't know if I should be tagging advice seeking questions as solved. Feedback from someone who knows about SL expectations or traditions would be appreciated.
I got what I needed from this question and the replies, doesn't mean I don’t appreciate more of it though. (lol although you might not be appreciating my appreciation)
0
Justice Thank you. May I ask what you mean by overdoing it? How do I understand that I should have to write at most "this" much and then leave the rest for myself to gather in the future? It feels like there are some obvious criteria that I am oblivious to.
I shouldn't spoonfeed myself right? It would be detrimental?