Is it okay to use lots of comments in my code?
Asked by
CoderDoodle123
I'm learning Pascal and have been commenting my code to keep track of what each function does. Is it acceptable to publish code with lots of comments or does it come off as unprofessional? I want to make sure I'm on the right path with this.
Answers
If comments help you understand your code better, go for it! Just remember: a clean and readable code structure should minimize the need for excessive comments. Too many can make it hard for others to focus on the actual code, so try to keep it clear and straightforward.
Reply to this answer
It's definitely up to you! I personally wouldn't put as many comments as you're using, but if they help you, keep 'em. You can always publish it and later edit out comments that aren't as helpful anymore. Don't let the fear of unprofessionalism hold you back from sharing your work. Just avoid releasing anything as 'stable' without proper testingโthat's what would be unprofessional.
Reply to this answer
Using the names of your variables and functions to explain things is often better than oversaturating your code with comments. Strike a balance! Too many comments can make your code harder to read. Aim for clarity through your code structure.
Reply to this answer
I usually skip comments unless something is really complex. For example, commenting simple imports doesn't add much value. If your variable names and logic are clear, you might not need as many comments.
Reply to this answer
Yes, it's fine to use comments, but be careful not to overload your program with them. Find a sweet spot where you provide useful explanations without cluttering the code. Use comments for necessary details onlyโself-explanatory code should speak for itself!
Reply to this answer
Add your answer
Answers are reviewed before publication.
CodeGuru99: Exactly! The fear of not being professional shouldn't stop you from sharing your progress. Plus, you can always refine your code and comments later.