5 ms·
Wow, you actually go that far? Adding links in code? I was with you on "not understanding discussion" because absolutely everyone in the workplace searches and
by exodust 10y ago
Wow, you actually go that far? Adding links in code? I was with you on "not understanding discussion" because absolutely everyone in the workplace searches and uses SO to find cool solutions, new tricks etc.
But adding those links to code I have never ever heard of! Not judging, but if I were working in your team I'd be like "ok, what clown is putting stack overflow links in the code!!"
- VLM 10y agoDifferent workplace cultures. Just like putting in academic citations on a clickbait site would be inappropriate vs not properly citing academic papers at uni is technically plagiarism. Its also for defense programming or documentation. "Why did you do that to that matrix to stabilize it?" "Well that is right out of Prof Higham's paper about nearest correlation matrices see this link in the comments, its not like I'm just making that stuff up as I go along". Also comes in handy for legal review. "Wait, thanks for the flattery but you can't copyright that, that algo is copied right out of Knuth, it was invented 50 years ago."
- ciaranm 10y agoWhy not? I've been known to do this as well. I'd rather put a quick link to a relevant source of information explaining why I did something the way I did than spend 2-3 lines trying to explain it. I probably most often use it when I've hacked around a known bug in someone elses framework - linking to the respective ticket, that way if someone comes along later and the ticket is resolved, they can remove/adjust whatever I've done. Links are everywhere else, why not in our comments?
- enraged_camel 10y agoASP.NET scaffolds in Visual Studio contain commented links to MSDN articles and documentation, and the links are clickable. So it has to be a fairly common practice. ;)
- ciokan 10y agoI often put links in the code as well and not because I'm a clown but because those discussions led to that code being there and those discussions explain the problem and solution in much detail usually. Nothing wrong with links in comments. I also place links to bug tickets waiting to be solved so I can track the progress without having to google for that bug each time I revise the code. I can go straight and see if it was fixed or not.
- trentmb 10y agoI usually add links too- it feels dishonest otherwise.
- TeMPOraL 10y agoI usually put links in comments when I copy out a piece of code (e.g. an utility function) wholesale, with maybe minor tweaks. It happens rarely to me, but when it does, it feels unfair not to credit the original author.
- hackinthebochs 10y agoContext in code is everything, and links provide the context far better than comments can most of the time. I find it surprising that you're so surprised at the idea of links in code!
- exodust 10y agoBecause it's only one tiny piece of any given function usually that we need help for from SO. That's my experience anyway. Usually it's how to do something, not copying and pasting huge chunks of code. And often I would change and modify what I learn from SO anyway,so it makes little sense to include links then.
- hackinthebochs 10y agoWell I'm certainly not littering my code with SO links. But when there's some particularly hairy problem that SO provided a solution, or an odd looking piece of code that I got from SO, I'll throw the link in. If the code is self explanatory or not particularly interesting, then there's no link. If its worthy of a comment, its usually worthy of a SO link.
- jestar_jokin 10y agoI do it for attribution, partly out of respect to the original authors, and partly to help resolve any licensing issues that may arrive - e.g. "This code was taken from a site with no clear license on its use, so we may need to replace it at some point."
- exodust 10y agoLicensing issues? I'm not talking about entire plugins, and I didn't think others were talking about that either. I thought we were talking about Stack Overflow, where we learn the best way to iterate an array backwards or something that amounts to a small component of what you're doing. In that circumstance (which is what Stack Overflow is mainly used for) links would not be necessary in your comments.
- JdeBP 10y ago> Licensing issues? [...] I thought we were talking about Stack Overflow Xe probably was. * https://meta.stackexchange.com/questions/272956/ https://meta.stackexchange.com/questions/272956/ * https://meta.stackexchange.com/questions/271080/ https://meta.stackexchange.com/questions/271080/ * https://meta.stackexchange.com/questions/25956/ https://meta.stackexchange.com/questions/25956/ * https://news.ycombinator.com/item?id=10905009 https://news.ycombinator.com/item?id=10905009
- exodust 10y agoThat's quite sad. Most of the time SO is a source of learning a new technique rather than copying code snippets letter for letter. We are shown a cool way of doing something with fewer lines of code for example, and we apply that method to our own projects. If someone wants attribution for code, it better be something self-contained with its own home on github or at least a blog somewhere with a unique name: "my awesome plugin v1.0".