|
||||||
| Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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.
|
| Sponsored Links |
|
|
|
|||
|
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 |
|
|||||
|
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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
Quote:
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";
}
|
|
|||||
|
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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
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. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java:Reference - Proper Comments | John | Java Tutorials | 5 | 02-04-2007 09:53 PM |
| Comments? | dirkfirst | JavaScript and CSS | 3 | 01-19-2007 09:29 AM |
| John | ........ | 223.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| LogicKills | ........ | 20.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 67%