Since comments don't do anything for the code, what's the purpose of them? I know all languages have them, and sometimes when I view the source code of things I see them, but they don't really say anything useful. I think worrying about them is a waste of time.
Comments are very important because if you look at your code a month after you create it you'll have no idea what you were doing and why you did it. With comments you don't have this problem. Also, comments are good if you are sharing work with another programmer.
DirkFirst Tutorials | Linux Forum
If the code is self-explanatory, there is no need for comments. Comments are useful for when you are doing something where either the algorithm or the technique is unclear. They are also useful in documenting specifications for functions or classes that someone else will be using. A common thing in programming is to have one person write a library for someone else, and only distribute the headers and compiled library. The person using the library can't see how things work, so must rely on the headers and comments to know what is legal and what isn't for that library.
Originally Posted by WingedPanther
With that being said, the person using the library couldn't use it unless there were comments. A good programmer always uses comments.
Code:for (int i;;) { cout << "Smith"; }
Alright, I understand. I'm sure it is especially important if you aren't the only person working on the code, because comments could also be used to tell your partner what to do.
It's also useful when you pick up code after working on other things for 6 months. There's nothing like looking at code that you KNOW made perfect sense when you wrote it and scratching your head.
Just a reminder: Comments aren't only for explaining the code (the how) but also for explaining why the code does what it does (the why).
If you're code isn't ridiculously complicated, it can be read and understood what it's doing...but without a comment, there's no way to know *why* it's doing it.
This is more of a topic for programming theory rather than language specific like Java.
food for thought.
icepack is right. Comments are important in ALL coding, whether its HTML, Java, C++ etc - you should comment in everything you do.
Well, I don't think they are very important in HTML as it is a very easy language to just look and see what is going on.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks