I use SO a lot, and I find it appropriate to cite the authors of some code/algorithm/method/ when I re-use it. When the question only has one answer, or contains itself relevant information, I just link to the full question page using the URL as shown in the browser.
But when I want to link to a specific answer, I have to either:
use the "share" button as-is. (This is horrible as the question title is hidden AND it leaks my user ID).
click the "share" button, copy the URL, paste it and let the browser resolve that to the full URL to the answer (cumbersome, and the URL contains duplicated anchor ID).
hack the source and build the URL myself (I did that before I realized I could let the browser resolve the "share" thing).
Not only none of these processes is satisfying, but I think this hinders a process that we should all be naturally following while programming and getting the help of others: proper citation.
Currently, not only do I link to the answer/question, but I also try to cite the author. Even if it's a nickname, but except if it's "userXYZ", I put something like (real example):
// Credit: Chris Lutz
// http://stackoverflow.com/questions/1493936/faster-approach-to-checking-for-an-all-zero-buffer-in-c/1493988#1493988
bool isBufferEmpty(uint8_t* buf, uint16_t size)
{
assert(buf);
assert(size >= 1);
return buf[0] == 0 && memcmp(buf, buf + 1, size - 1) == 0;
}
The problem is that this format varies (depending on the day, my mood, my typos, etc.) Scientific literature has very strict guidelines (and requirements for citations). I think we could be inspired by this - although we don't need to be as rigorous.
Now my question:
Can we have a "cite" button, ideally located just next to the "share" button, that provides a proper citation with the name of the author(s), possibly the date, and the full URL to the answer ? We should be able to paste the snippet as-is directly in our code, with minimal need for reformatting. The dialog could typically have a few configuration buttons for the style of comment (maybe //, /* */, # and %)
Edit (clarifying why I think long, descriptive URLs are better than short permalinks, and also why I never use URL shorteners): I think there are two arguments here.
The first one is cognitive. When one reads source code, or any other form of documentation, one does not have enough time to read all references - this is just impossible. Back when I was a researcher, I would scrape the list of references, then maybe peek at 2-3 papers (of course it depended on how on-topic with my research the paper was). I think the same applies to source code when reviewed by me or my peers. If, as a reviewer, I see a short URL, I have no idea what is there, if it's relevant to what I am doing or not. If I see a descriptive title, I can read the content linked to if I am interested. I simply have more information to drive my decisions. Just imagine if reference in papers were only DOIs (document identifiers)!
The second may be of less importance, but anyway: if for some reason the content disappears (because the question is deleted, because StackOverflow goes out of business, etc.) we still have some keywords. Chances are there is some similar content somewhere on the web. The key is: these keywords can help you be back on track faster if the source disappears.
Share
link contains the UserID solely for badge counting (there are badges for sharing links viewed by x-number of people).http://meta.stackoverflow.com/questions/316496/citation-for-linking-to-answers/316529#316529
is a link to Michael Dibbets's answer to this question. It doesn't matter if somebody else adds an answer, that link will always point to Michael's answer (unless the answer is deleted). If the title changes, the link will still work; for the OP's use case, as long as the title in the URL is a clear description of the problem, I don't think it would be a big deal if the title is changed to not match the original link.http://meta.stackoverflow.com/q/316496/1935077
andhttp://meta.stackoverflow.com/q/316496
works the same (except it won't count for badges).http://meta.stackoverflow.com/questions/316496/the-sum-of-all-unicorns-is-42#316529
). So if the title changes, the URL will still work. Besides, I consider the short URL obfuscated rather than concise. (OTOH, there are sites that have awful deep URLs, but that's not the case of SO).