|
-
April 2nd, 2002, 06:01 AM
#1
Quote from some guy: "Why comment, the code was hard to write, it should be hard to read!"
Seriously, commenting is very important... Some members here have been saying that they don't bother commenting since they're the only one coding the project, or even they only coder in the company. While it might provide *some* job security when you're the only one who can understand the code, that excuse dosen't last long... What's more, think about the poor guys who'll have to maintain the code later... That guy might even be you... Will you remeber what that twisted algo. does in 2, 5, 10 years??? Think about the life expectency of your program: who would have tought that programs coded in the 70's would still be around in 2000, and have to be patched in 97-98-99 cuz of the y2k bug? The biggest cost of information systems is maintenance...
As for commenting strategies:
-First of all, a single fonction should do ONE and only one thing and do it well... That forces you to have well structured code that's easy to understand and requires less commenting.
-Second, name your variables appropriately. You should have documented/standardized coding practices.
-Thrid, if you need sooo much comments to make your code understandable, you're probably doing something wrong... Don't put useless/obvious comments like "x = y; // Sets x to y's value"... Also, get to the point with your comments: don't write a story...
Don't get me wrong, comments are good, just don't try to compensate bad code with alot of comments.
Personnaly, I sometimes do the following:
Comment BEFORE coding when coding complex algos: it helps you keep in mind what you're doing and what you want to do...
Comment WHY certain calls must be maid, or why it must be done a certain way.
Of course, comment APIs; Javadoc is great for that.
Well, that's my 2 cents...
(I might/probably have re-stated some of the previous posts.. Credit goes to the first to have said it 
Ammo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|