There seems to have been a marked increase (at least on the C++ tags) of people asking questions and referring the reader to code posted on pastebin and similar sites. I always post a comment on these telling the questioner to post the code on SO, and refuse to answer until they do so.

Would it not be possible to detect pastebin and similar URLs in the question, and to at least give a warning that this is not good practice?

Ban then, and then warn them. Its the only way to be sure.
–
Won'tJun 13 '11 at 12:44

1

Just came to complain about this, starting to find more and more dead links to pastebin where the content has expired, makes our huge archive of useful answers to questions utterly useless.
–
LouisSep 26 '11 at 0:43

Although I understand it's very nice to ensure you actually do get the code (because broken links happen), it's important to realize that posting code here will give the code the CC-BY-SA license, which even according to the makers of CC is not a software license, and it's incompatible with the GPL. People don't want to make their code so they can't use it in open source projects or for their businesses proprietary projects and such; so, I think it makes perfect sense to use pastebin until stackexchange changes their license policy to allow for such as MIT (or at least GPL) licensed code.
–
ShuleOct 30 '14 at 10:33

However, I think people who post their stuff on external sites should still explain the algorithm and declare a license. However, I think this practice would be much more acceptable in answers than questions (which questions typically don't use exact code, anyway).
–
ShuleOct 30 '14 at 10:42

3 Answers
3

I agree with you that the code should always be present in the question so that a user can read the question and understand it in it's entirety without visiting external sites. However, This could be a problem on the JS tags as we encourage people to post a link to jsfiddle or jsbin in addition to the code in the question.

I agree; however the JSFiddle is usually done so to reproduce the problem, the answer should be explained on SO directly as to not requiring external resources. Dead links to answers you need are an utter pain.
–
LouisSep 26 '11 at 0:45

My experience (mostly reading the C, C++ and Java tags) has been that questions on pastebin and co. are often of low quality, even if you imagined that the code in question was inlined.

Usually this is indicative of another problem - "my code is too big to fit sensibly in a question page", which seems to make for a poor question regardless of where the code is hosted. 200 lines taken directly from a 100K LOC project is really hard to analyze in any meaningful way and often the problem itself stems from undefined behaviour elsewhere.

Some kind of warning about good questions using short, self contained correct examples, with all the benefits they bring would, in my view, help improve the quality of some of these questions.

Actually, some other sites provide some functionality (e.g. jsfiddle), that makes it easier to work on the question. What we should think about is to have some code from those sites to automatically be included in the answer, if a link to such a site is posted. That way, we preserve the code from disappearing and still will be able to use the extended functionality of those specialized sites.