Take the 2-minute tour ×

In quite some codebase you can see comments stating things like:


So I've got a few questions, but they're all related.


 // re-inventing a wheel.
 // (see why here, in SO question: http://stackoverflow.com/questions/951848)

Do you do it?


share|improve this question

migrated from stackoverflow.com Feb 3 '12 at 3:01

This question came from our site for professional and enthusiast programmers.

@Robert S.: no, it's not a meta. It's not about SO: I'm accepting SO the way it is. This is specifically about how to deal with a SO-like resource from a comment. –  Tristan St. May 17 '10 at 16:53
Are you talking about code which you write for your team? Ask them. –  Aryabhatta May 19 '10 at 20:47
You can always save the whole web page as a complete web page, zip it and put it in your documentary folder. –  user1249 Feb 3 '12 at 9:21

5 Answers 5




share|improve this answer

Ideally your code needs no such comments because it's well structured, etc. But yes, when your situation is less than ideal, it's acceptable to put in comments like this. And links to stackoverflow.com are as good (and often better!) than others.


I have not yet put a StackOverflow.com link in my code. I try to avoid putting links in code, since it's a bad smell, but when the time comes I won't hesitate.

Edit: I think my above answer gives the impression that the need for comments such as this is avoidable. Of course sometimes it's not avoidable; it's a bug in a library or poor API design that you have no control over. Comments like this, including links, is very helpful for the next developer to come along.

share|improve this answer
hey, look at that one, I wish there would a "cleaner" way to deal with it, but very often it's not the case stackoverflow.com/questions/951848 I mean, bugs and inconsistencies/weird API, undocumented behavior, etc. are part of our programmer lifes :) –  Tristan St. May 17 '10 at 16:51


share|improve this answer
that's interesting: so you're actually suggesting that in the case of an SO answer I could fetch the HTML and store it in my DVCS (Mercurial but that's not the point)? –  Tristan St. May 17 '10 at 16:53
Well, normally you don't need the whole thing, just the relevant bits right? And you can reference the source. –  Loki May 20 '10 at 17:25

I view it like writing a research paper. If I use someone else's ideas, then I need to give credit for those ideas. I have used an answer from stackoverflow in my code before, and I added the link to the comments of method.

As someone mentioned, SO is a wiki style, so it's possible that it could change, but generally the idea should still be the same.

You should still give credit to others when you use their ideas.

share|improve this answer

If you have needed to implement a work-around, and it is not obvious why the implementation was done a particular way, then a comment really should be let to identify the reasons why. I think placing a link to an online reference is fine, but you really need to have made your comment succinct, yet complete enough that the link will only provide an expanded explanation should the reader feel a need to double check your reasoning.

If on the other hand the code has been copied verbatim, then a link to the original source is only fair, and may be required depending on the wording of the license under which you have been allowed to copy the original author's work.

share|improve this answer

Your Answer


