Everything2
Near Matches
Ignore Exact
Full Text
Everything2

comment-to-code ratio

created by -brazil-

(thing) by -brazil- (2.7 y) (print)   ?   (I like it!) Wed Jul 11 2001 at 8:26:42

The ratio of a given amount of source code that is dedicated to comments. The importance of comments cannot be overstressed, as understanding a piece of code is always much, much more difficult for anyone who hasn't written it himself. And even the author often has problems understanding it when he looks at it years later.

Dismissing comments as unnecessary because Good code is self-commenting is downright wrong for most nontrivial tasks where the individual commands reveal little about what is actually being done on a higher level. Even if the code is self-commenting, natural language comments are usually easier and quicker to understand, especially in the case of high-level abstract descriptions of what a whole function, module or class does.

The Infospheres team of Caltech has this to say about the comment-to-code ratio in their coding standards:

  • Horribly commented code averages 0-5% comment ratio.
  • Poorly commented code has a 5-10% comment ratio.
  • Average code has a 10-15% comment ratio.
  • Good code has a 15-25% comment ratio.
  • Excellent code has a > 25% comment ratio.
The code that we release averages approximately a 45% comment ratio.
Much of the Linux kernel also serves as a good example, having a very high ratio of comments. So follow these exampes and don't be lazy. Comment your code!

printable version
chaos

But who codes the coders? When good code goes bad coding standards Learn C, you hippies
Why programmers don't comment their code lines of code naming convention This program cannot be run in DOS mode
Linux kernel class The Internet Cannot Be Stored In Your Recycle Bin Caltech
source code Things to consider if you think someone might be dead Ben and Jerry's comment
Chatterbox D.H. Lawrence eLOC Programming
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Just another sprinkling of indeterminacy
Keyboards in a computer lab with very sticky keys that make you
Shadow of the Colossus
Bauhaus
sexagesimal numbers
Ferengi
((Cover))
Jacob: Alone
Is file sharing theft?
fibromyalgia
How to tell whether a figure can be drawn in one stroke
It's the Season for Graves Cracking: The 2006 Quest for Fear
The best compliment an actor can receive
Tijuana Bible
New Writeups
Aerobe
Watch out for falling meat(poetry)
C-Dawg
Beelzebub has a devil put aside for me(fiction)
Pavlovna
My Better Half(fiction)
kanoodle
Molson muscle(essay)
aneurin
You pays your money and you takes your choice(idea)
shaogo
July 20, 2008(log)
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
John_Fox
Good Intentions Gone Wrong(person)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
Everything 2 is brought to you by the letter C and The Everything Development Company