Hey, what distro are you running? Debian 3.1 (Sarge) doesn't have rails in its repository. I had to manually install ruby-gems and use it to install rails. And ruby-gems wouldn't install where I wanted it to.
I would agree with that. I also agree that it's a tad difficult to distinguish between why and what.
Most of the why folks seem to think that comments should be reserved for things like "chose algorithm X because Knuth says it's fast". While I agree that should be included, I also think it's helpful to use comments such as "frobulate the widget". Not when the code reads "widget.frobulate()", but when the code is more like "fr = getFrobulator(xyz.widget.picElement[1]); fr.frobulate(xyz.widget.contexts[3]);". And no, it does not always make sense to factor that out into a separate method to make the code completely self-documenting. In this example, you'll often want to choose a different picElement or context.
This guy does a good job of explaining why versus what comments. I also found this subthread to have good discussion of the topic.
I think everyone here, and everyone past first-semester programming classes would agree with that. The big argument here seems to be whether to comment on what the code does. I seem to be in the minority who believe that comments should tell what. But even your example better answers what you're doing than why. Note that the what people seem to want to comment a bit more than the why people, and in fact there's a large portion (like me) who write the what comments before the code.
Comments should never describe what the code does.
It seems that most folks here believe that -- that you should only comment on why you're doing things, not what you're doing. But I think that's a bad idea. For example, let's say you've got some "code" that says:
Combine an egg, some flour, some milk, some sugar,...
I would contend that the comment should be "make a cake". I suppose you could contend that tells why we're combining the ingredients, but I think it's more clear to say that that is what we're doing. My point is that what we're doing is not at all obvious from just looking at how we did it.
I suppose my (Slashdot) comment fits in here well.
I write my comments first. I figure out what needs to be done and write it down in comments. Then I flesh out the code to do what the comments say. In this way, I tend to have a comment every few lines. Almost always 1 full sentence. The comments are never of the form "add a and b", unless I'm writing out a formula I derived or copied from somewhere. Occasionally, I'll end up with comments that mirror the code pretty closely, but less often than you might think.
I find that my commenting method/style helps me in several ways:
I can write my "spec" before writing my code, to get the pseudo-code straight in my head.
I can not implement certain parts, and leave them to do later, without losing too much context, and with a clear indication of what I left out.
I find that my comments never get out of sync with my code.
I can come back to my code much later and quickly understand what it does.
Here's a random example from some JavaScript slide-show code. Note that you can see what the code does by just reading the comments. I only leave the "how" part to the code.
// Get a list of all slides (elements with class="slide").
slides = getElementsByClass( "slide" );
// See if the user specified a specific slide in the URL.
var page = location.hash.substring(1);
// Make sure the requested slide exists, or default to 1st page.
if ( page != 'all' && isNaN( page ) || page < 1 || page >= slides.length )
{
page = 1;
}
// Get the drop-down element.
var dropdown = document.controls.Goto;
// Add an option to the drop-down for each slide.
for ( var i = 1; i <= slides.length; i++ )
{
if ( IE )
{
slidetitle = i + ' - ' + slides[i-1].childNodes.item(0).innerText;
}
else
{
slidetitle = i + ' - ' + slides[i-1].childNodes.item(1).childNodes.item(0). data;
}
addOptionToSelection( dropdown, slidetitle, i );
}
Hey, you mean I get to choose which cable company runs their line to my house? No? Then it's not a free market, is it? It's a natural monopoly. And we should treat it as such. Ever notice how the gas and electric companies have to ask a government commission whenever they want to raise prices?
I don't see the problem with the ESRB rating system, and starting over if you don't like the rating you get. This is EXACTLY how the MPAA rates movies. There are numerous cases of a movie getting an X/NC-17 or an R and the producers re-editing the movie to get an R or a PG-13.
Makes sense. Toilets and Windows are both measured in GPFs. For Windows, that's General Protection Faults (AKA blue screens of death, AKA BSOD, AKA crashes). For toilets (in the USA, at least) GPF is the rating of how much water it uses - Gallons Per Flush. I've seen many urinals with the GPF rating printed on it.
OK, I know that the article is not about GOTO statements. However, I'd like to respond to everyone saying that GOTO statements are bad.
The reason GOTO statements are bad is not speed. The reason GOTO is harmful is because it leads to spaghetti code, which confuses programmers. In pin-hole optimizations, GOTO can actually speed things up in many situations. And it's probably impossible on most architectures for your machine language not to have GOTO (jump) statements. In fact, there are architectures that have an explicit GOTO statement in every instruction.
I'd recommend IMAPS (IMAP with SSL) for a secure connection between your client and server. And a webmail client that accesses the IMAPS server as well. Whether you should do it yourself or subscribe to a service depends on how much time you want to spend setting it up (assuming you have the skills to do so -- it's not trivial).
Um, my question was pretty clear in asking for experimental evidence supporting the theory. I've no idea how you could have mis-construed it as asking for 100% provability, a la the anti-Evolution crowd. And thanks for not answering my question.
How much experimental evidence do we have to prove the Heisenberg Uncertainty Principle? I couldn't find anything in the Wikipedia article providing any verification of the principle. If Einstein was right in his arguments, then it's possible that there are missing variables underlying quantum states that could be measured, correct?
The biggest problem with that is that the GNU GPL doesn't require you to agree to the license in order to use the software. You only have to agree to the license in order to copy, modify, or distribute the program. Why? Because that's all copyright applies to -- copying, modifying, and distributing. Copyright doesn't stop people from reading books -- it stops them from copying books, distributing copies, or distributing modified copies.
One method that works extremely well to measure response to a particular ad is to use a separate phone number for each ad or campaign. You've probably seen something similar with URLs listed in magazines, where they put a URL such as www.mysite.com/nw in News Week. Granted, it's not perfect, and it only works for a small number of ads/campaigns active at once, but it can give a pretty accurate measurement. Also, for weekly ads in a newspaper, 99% of the calls will be due to that week's ad, not a previous one. So they can compare weeks against each other to see which ad was more effective.
Come on. Are we really supposed to believe that they had a Director of Product Marketing named Mike Evangelist? And I suppose they've got an engineer named Dave Engineer too. And users named Joe Sixpack. And an HR guy named Steve Jobs.
Great idea on testing your current current draw. I picked up an inline watt-meter at Radio Shack. I think I only paid $20. I was surprised to see it in the store, and since it was nicely priced, I picked one up. I was surprised at the wattage of different devices in my house. My PCs used quite a bit less than I would have expected.
That's ridiculous. Let's say you're taken to court by the author of a piece of software that was released as "public domain". You argue that it was clearly the intention of the author to allow any use, as if it were truly in the public domain due to an expired license. What judge or jury wouldn't accept that argument? (Assume there are no non-copyright issues involved in this case.) So while there may not be any way to truly place something in the public domain, merely making it clear that that is your intention will have the same effect.
I second that. I bought a Mac mini the day they were released. I'd said since OS X came out that I'd buy a Mac if the prices were reasonable. And to me, the $500 starting price was quite reasonable for a computer to hook up to my HDTV. (I spent nearly $800, including the upgrades.) I'd used Macs frequently before, but never thought they were worth the extra cost.
Just last week, I recommended a Mac mini to a small business owner whose PC got infected by viruses and spyware. I told them that it would be a lot easier to support a Mac, and wouldn't require all the anti-malware software. The owner ended up buying one for his receptionist as well.
I wasn't really interested in the iPods at all. In fact, I'm more interested in an iPod nano now, BECAUSE of my Mac. I'm more interested in the NeXT-based OS, because I used NeXTs in college; and the ease of use combined with UNIX underpinnings. For other people, I recommend the Mac mini because of the ease of use, reduced maintenance requirements, and lack of security issues that Windows has.
Hey, what distro are you running? Debian 3.1 (Sarge) doesn't have rails in its repository. I had to manually install ruby-gems and use it to install rails. And ruby-gems wouldn't install where I wanted it to.
It's even worse than I thought!
I own a small store, and a lot of people come in to browse and don't buy anything.
The bus companies are making money off of people who come into my store!
Let's say you are baking a cake. Someone asks you "what are you doing?". Would you really answer "I'm combining ingredients"?
I would agree with that. I also agree that it's a tad difficult to distinguish between why and what.
Most of the why folks seem to think that comments should be reserved for things like "chose algorithm X because Knuth says it's fast". While I agree that should be included, I also think it's helpful to use comments such as "frobulate the widget". Not when the code reads "widget.frobulate()", but when the code is more like "fr = getFrobulator(xyz.widget.picElement[1]); fr.frobulate(xyz.widget.contexts[3]);". And no, it does not always make sense to factor that out into a separate method to make the code completely self-documenting. In this example, you'll often want to choose a different picElement or context.
This guy does a good job of explaining why versus what comments. I also found this subthread to have good discussion of the topic.
I think everyone here, and everyone past first-semester programming classes would agree with that. The big argument here seems to be whether to comment on what the code does. I seem to be in the minority who believe that comments should tell what. But even your example better answers what you're doing than why. Note that the what people seem to want to comment a bit more than the why people, and in fact there's a large portion (like me) who write the what comments before the code.
It seems that most folks here believe that -- that you should only comment on why you're doing things, not what you're doing. But I think that's a bad idea. For example, let's say you've got some "code" that says:
I would contend that the comment should be "make a cake". I suppose you could contend that tells why we're combining the ingredients, but I think it's more clear to say that that is what we're doing. My point is that what we're doing is not at all obvious from just looking at how we did it.
I write my comments first. I figure out what needs to be done and write it down in comments. Then I flesh out the code to do what the comments say. In this way, I tend to have a comment every few lines. Almost always 1 full sentence. The comments are never of the form "add a and b", unless I'm writing out a formula I derived or copied from somewhere. Occasionally, I'll end up with comments that mirror the code pretty closely, but less often than you might think.
I find that my commenting method/style helps me in several ways:
Here's a random example from some JavaScript slide-show code. Note that you can see what the code does by just reading the comments. I only leave the "how" part to the code.
Hey, you mean I get to choose which cable company runs their line to my house? No? Then it's not a free market, is it? It's a natural monopoly. And we should treat it as such. Ever notice how the gas and electric companies have to ask a government commission whenever they want to raise prices?
I don't see the problem with the ESRB rating system, and starting over if you don't like the rating you get. This is EXACTLY how the MPAA rates movies. There are numerous cases of a movie getting an X/NC-17 or an R and the producers re-editing the movie to get an R or a PG-13.
There are so many Uranus jokes, I think we should rename the planet. I suggest "Urectum".
(obFuturamaReference)
Makes sense. Toilets and Windows are both measured in GPFs. For Windows, that's General Protection Faults (AKA blue screens of death, AKA BSOD, AKA crashes). For toilets (in the USA, at least) GPF is the rating of how much water it uses - Gallons Per Flush. I've seen many urinals with the GPF rating printed on it.
OK, I know that the article is not about GOTO statements. However, I'd like to respond to everyone saying that GOTO statements are bad.
The reason GOTO statements are bad is not speed. The reason GOTO is harmful is because it leads to spaghetti code, which confuses programmers. In pin-hole optimizations, GOTO can actually speed things up in many situations. And it's probably impossible on most architectures for your machine language not to have GOTO (jump) statements. In fact, there are architectures that have an explicit GOTO statement in every instruction.
I'd recommend IMAPS (IMAP with SSL) for a secure connection between your client and server. And a webmail client that accesses the IMAPS server as well. Whether you should do it yourself or subscribe to a service depends on how much time you want to spend setting it up (assuming you have the skills to do so -- it's not trivial).
Um, my question was pretty clear in asking for experimental evidence supporting the theory. I've no idea how you could have mis-construed it as asking for 100% provability, a la the anti-Evolution crowd. And thanks for not answering my question.
FDIC? I don't think they have jurisdiction over anything besides banks. Perhaps you meant the SEC?
How much experimental evidence do we have to prove the Heisenberg Uncertainty Principle? I couldn't find anything in the Wikipedia article providing any verification of the principle. If Einstein was right in his arguments, then it's possible that there are missing variables underlying quantum states that could be measured, correct?
Well, the Wired site is the one that's not working now. Unfortunately, Coral Cache doesn't seem to have a copy.
The biggest problem with that is that the GNU GPL doesn't require you to agree to the license in order to use the software. You only have to agree to the license in order to copy, modify, or distribute the program. Why? Because that's all copyright applies to -- copying, modifying, and distributing. Copyright doesn't stop people from reading books -- it stops them from copying books, distributing copies, or distributing modified copies.
One method that works extremely well to measure response to a particular ad is to use a separate phone number for each ad or campaign. You've probably seen something similar with URLs listed in magazines, where they put a URL such as www.mysite.com/nw in News Week. Granted, it's not perfect, and it only works for a small number of ads/campaigns active at once, but it can give a pretty accurate measurement. Also, for weekly ads in a newspaper, 99% of the calls will be due to that week's ad, not a previous one. So they can compare weeks against each other to see which ad was more effective.
No, a EULA applies to the company if you are installing the software on behalf of a company.
The method for protecting your code from being copied is called "copyright". Really, that's the whole reason for the existence of copyright.
Come on. Are we really supposed to believe that they had a Director of Product Marketing named Mike Evangelist? And I suppose they've got an engineer named Dave Engineer too. And users named Joe Sixpack. And an HR guy named Steve Jobs.
Great idea on testing your current current draw. I picked up an inline watt-meter at Radio Shack. I think I only paid $20. I was surprised to see it in the store, and since it was nicely priced, I picked one up. I was surprised at the wattage of different devices in my house. My PCs used quite a bit less than I would have expected.
That's ridiculous. Let's say you're taken to court by the author of a piece of software that was released as "public domain". You argue that it was clearly the intention of the author to allow any use, as if it were truly in the public domain due to an expired license. What judge or jury wouldn't accept that argument? (Assume there are no non-copyright issues involved in this case.) So while there may not be any way to truly place something in the public domain, merely making it clear that that is your intention will have the same effect.
Now, where things get sticky is if the author releases something without a clear intention of relinquishing all his rights.
I second that. I bought a Mac mini the day they were released. I'd said since OS X came out that I'd buy a Mac if the prices were reasonable. And to me, the $500 starting price was quite reasonable for a computer to hook up to my HDTV. (I spent nearly $800, including the upgrades.) I'd used Macs frequently before, but never thought they were worth the extra cost.
Just last week, I recommended a Mac mini to a small business owner whose PC got infected by viruses and spyware. I told them that it would be a lot easier to support a Mac, and wouldn't require all the anti-malware software. The owner ended up buying one for his receptionist as well.
I wasn't really interested in the iPods at all. In fact, I'm more interested in an iPod nano now, BECAUSE of my Mac. I'm more interested in the NeXT-based OS, because I used NeXTs in college; and the ease of use combined with UNIX underpinnings. For other people, I recommend the Mac mini because of the ease of use, reduced maintenance requirements, and lack of security issues that Windows has.