391 Comments
- inactive, on 07/27/2008, -8/+404no coding knowledge whatesover, but ill digg it anway just to help keep digg atleast slightly tech related.
- magamiako, on 07/27/2008, -17/+310Reason #1 to not comment your code: Job Security.
Don't comment your code, it makes it easier for someone else to understand and thus allows you to be replaced with someone making 1/2 your salary. - FiP0, on 07/27/2008, -1/+173Coding horror : Coding Without Comments
http://www.codinghorror.com/blog/archives/001150.h ... - headzoo, on 07/27/2008, -1/+153Commenting is a must, but we could all do without comments like this:
/* Get user data */
user = db.getUserData(1);
Right.. Like we couldn't figure out what that line of code was doing without the oh so helpful comment above it. - valan, on 07/27/2008, -0/+128One time I was working on a very badly written site, and came across a comment that said, "[Bob Smith] is the WORST programmer I have ever seen and I pity any person who has to work on this site." It actually made me feel a little better.
- chincopanda, on 07/27/2008, -0/+117 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!IF YOU CHANGE TABS TO SPACES, YOU WILL BE KILLED!!!!!!!
* !!!!!!!!!!!!!!DOING SO ***** THE BUILD PROCESS!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- inactive, on 07/27/2008, -2/+107// add one to i
++i; - inactive, on 07/27/2008, -0/+96A front-page programming article? On my Digg?!
The nostalgia. - LucasVB, on 07/27/2008, -0/+76Thank you.
- Shogi, on 07/27/2008, -10/+80Commenting saves tons of time and prevents incidents of "magic code" and helps prevent coding insanity.
Please, comment your code. - FutureEng, on 07/27/2008, -1/+68Sad, but true. But you have to make sure you remember how you did it 4 months ago. Otherwise you'll need the comments for yourself.
- inactive, on 07/27/2008, -0/+67/* Will Do */
- glinsvad, on 07/27/2008, -3/+64my commenting consists solely of the names of the variables/class/methods in use.
double getSquareRootOfTheStuffYouNeedToCalculateTheSquareRootOf(double theValueINeedToFindTheSquareRootOf)
{
int theValueIThinkIsCloseToTheSquareRootOfTheValueIAmTryingToFindTheSquareRootOf = ... - lewhich, on 07/27/2008, -2/+62Such a wise response, can only come from a veteran programmer.
As a matter of fact, you should obfuscate your code so only you can understand - Job security my men, thats what all contractors do here in DC. - superkendall, on 07/27/2008, -2/+49I've read that code that has too many comments.
I've also read code, that has comments that were misleading - that's the worst problem that can happen with comments, is they get out of sync.
That said comments are important, but I think they should be terse enough generally that keeping them in sync is easy for whoever is working on the code. On some occasions, when you are doing something tricky that will not change much then really verbose comments are warranted.
To my mind comments should follow ideologically in line with Knuth's idea of literal programming - you describe what you are going to do, then code builds around the comments to do what you wanted. Then it's more natural to update the comments as you need to type out what you are thinking before you go do.
Just like with anything else, I don't think you can apply a single guideline to anyone or any code base - it's all dependent on the context the code lives in. - DaAvalanche, on 07/27/2008, -4/+50The opposite side of that is that you can never get promoted either..
- inactive, on 07/27/2008, -4/+48Kudos to you crazy programmers. What a cryptic and confusing world you guys must live in.
Don't digg me down since I don't know anything about programming but why do you guys need to comment a language that you're supposed to understand?
It would be like writing a novel in French and having to reiterate it in English to a native French speaker.
I would buy you guys all a round of beer if I could. - rhys18383, on 07/27/2008, -1/+42Look for a new job
- nicerobot, on 07/27/2008, -4/+44"You should always write your code as if comments didn't exist."
A real problem with inline comments is that they must change as code changes and there is no verification that they match. When someone is under pressure to produce, secondary content that doesn't affect the result will be easily overlooked. Wrong comments are worse than no comments.
Code is always the source of truth and, as such, should be written with names that explain their purpose. Inline comments should be used sparingly. Summary comments can and should be quite detailed to explain the goal of large sections of code.
The code will tell me right away if I need to pay more attention to the comments. When reading well-written code, comments are secondary unless you're learning the language. Otherwise, they are more of a distraction. I read most programming languages almost as easily as I read my native speaking language. It's when programs are littered with short, similar abbreviations for variables and routines does it become cumbersome to comprehend. - superkendall, on 07/27/2008, -1/+36A company that silly will never actually examine your code. Willfully ignore it.
- fryguy1013, on 07/27/2008, -1/+35Rule for good comments: Write why, not what.
And yes, there is such a thing as having too many comments. - inactive, on 07/27/2008, -2/+31False.
- jggube, on 07/27/2008, -0/+28//Do not remove the code below this comment, it will cause the server to crash.
- falafelkiosken, on 07/27/2008, -0/+27or even better, write your comments in Elvish
- AgentAnderson, on 07/27/2008, -0/+27What is the "1" argument for?
COMMENT ABOUT THAT! - jggube, on 07/27/2008, -2/+28// sweet
- allengeer, on 07/27/2008, -2/+28if your good, and i mean really good, your variables/class/methods read like comments if you reverse them
for (int drenami = 0; i < ggidyay; i++ ) {
ffutsemos.od(sdfsdf);
} - matt646, on 07/27/2008, -0/+24# thanks
- gobbleplex, on 07/27/2008, -0/+22That's not job security. Who can't read elvish?
- drgirlfriend, on 07/27/2008, -0/+22< !--awesome-- >
- JoshReedSchramm, on 01/29/2009, -3/+24I'll go ahead and defend Jeff's opinion on this.
90% of applications written are business aps. Generally these apps have very little complex logic besides formulas the business itself uses. In this case Jeff's approach to commenting is completely valid. Comments that explain what the code is and does are redundant. Time is better spend rewriting your code so that the developer who comes after you can understand the process intuitively. Comments do go out of date as does business logic. Saying to "keep them up to date" is oversimplifying the problem. Why? Because if a customer comes to you and asks for a change you HAVE to change the code. you dont have to change the comments and many lazy maintenance developers will take just that tact. (or maybe they arnt lazy but constrained by a ridiculous deadline)
That said commenting does have it's place. Generally it's acceptable and encouraged for situations where
1) The code chooses a design pattern that isnt "standard", i.e. there is some compelling reason why a non-standard approach was taken (maybe performance was more important for example). This is rare but does occur.
2) The logic is overly complex and there isnt a think you can do about it. If your writing code to launch a rocket to mars or map the human genome comments are probably just fine.
New developers are taught to comment everything because they aren't yet at a point where they understand how to write transparent and maintainable code. Academia teaches commenting because code NEVER has to be maintainable. I mean seriously how many classes has anyone had where a professor said "ok now take out that application you wrote in CS 101 and make some changes" 4 years later. It doesn't happen. - ir1337, on 07/27/2008, -1/+22comment your code to death. encrypt the file. save it to removable media. publish the code, stripped of all comments. job security ftw. unless you work for a company that has oversight, which imho, most employers regard oversight as the tenth wall, and plan to implement once they have monopolized their market.
- stevan2002, on 07/27/2008, -4/+24TO MANY COMMENTS IS BAD!
Wow, I have read code with to many comments, and I can't stand it. if you create a class, I don't need you to tell me that, if you are assigning a variable called, length, I don't want to see /* LENGTH of my rectangle */ or some stupid ***** like that.
Also, I hate reading novels when looking at comments. They should be short and sweet. - plarp, on 07/27/2008, -3/+23comments are useless without coding standards.. i don't care how commented code is.. if it is not within the standard agreed upon.. it gets tossed.
code uniformity > comments. - kahrn, on 07/27/2008, -1/+21Valid question. The simplest answer I could give is "because it's nothing like a spoken language". Think of it as 'code documentation'. When viewing someone elses code, unless it is very clear or you designed it yourself you will most likely have no idea on how it works, or why it works. x = 5.. but why does x = 5? get it..?
- random12345, on 11/16/2008, -0/+19// server down due to digg effect
// attempt to ask for mirror - eggsovereasy, on 07/27/2008, -0/+19-- that's great
- Black6x, on 07/27/2008, -1/+20My Digg comments are so great that they don't need comments.
- d03boy, on 07/27/2008, -0/+19' oh *****, vb...
- banmaster, on 07/27/2008, -0/+18Spaghetti Code = Job Security
- Sivvy, on 07/27/2008, -1/+18It's Quake 3's fast invsqrt() function, using a 'magic' constant.
http://www.beyond3d.com/content/articles/8/ - ralphthemagi, on 07/28/2008, -1/+18How is that a solution? Any coder can read that.
- course6, on 07/27/2008, -0/+17@superkendall
cincopanda is referencing one of the comments found in the leaked Windows 2k codebase. ;)
http://www.kuro5hin.org/story/2004/2/15/71552/7795 - MavRevMatt, on 07/27/2008, -2/+17too*
- TheChunt, on 07/27/2008, -9/+24I try and take it one step further. I'll incorrectly comment/label my methods whenever possible. The confusion that comes about when a save button is hooked up to a method named delete is great to watch.
- falafelkiosken, on 07/27/2008, -0/+15my favorite is
- (void)someFunction {
/* Do nothing */
} - inactive, on 07/27/2008, -0/+15Cheers to fellow DC contractors.
- magamiako, on 07/27/2008, -0/+14haha.
- frostw, on 07/27/2008, -1/+15Hi Bob
- benologist, on 07/27/2008, -1/+15// zero
public const int Zero = 0; -
Show 51 - 100 of 393 discussions



What is Digg?