What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

Today I answered a question, but I was reluctant to include a long code example (original) demonstrating the solution strategy I proposed in my answer.

Is it a good thing, or allowed, to post a link to a code sample on some public access point like DropBox as part of an answer?

share|improve this question

2 Answers 2

An answer should not rely on an external source to be understandable. Answers (and questions) on SE sites are thought to be a durable resource of information, and not as a temporary solution resolver for the OP; it should help the OP, and any other user with the same problem to solve.

If the question is about code, then the answer should report the part of code that is necessary. If you want to provide a link to a repository containing the complete code, that is fine, but the answer should not depend from it; the link to the complete code should be something extra, where the parts of the code that are important for answering are already reported in the answer.

Similarly, questions should contain the strictly necessary code; eventually, the question can contain a link to a repository containing the complete code, but that should be an extra, and the question should be clear even in the case the link doesn't work.
In the case of questions, if they need a lot of code, then the OP is probably asking multiple questions that should better be asked as different questions.

share|improve this answer
    
Hi, In this case I assert that my answer is a proposed outline of a strategy for a code solution that does not require an external source. Adding in the code would result in an already long response being, imho, too long. Your generalizations about what questions should be like are not relevant to the question asked here which is about an answer. thanks, Bill –  BillW Jun 19 '11 at 14:18
    
@BillW My answer is still valid. Just putting a link to an external source that contains a long code is not something that you should do; first add the relevant code in the answer, and then (eventually) add the link to the external source containing the full code. What I added about the questions is to say that what reported about links in questions is still valid about links in answers; if you find a question on meta about links on questions (and what to quote from the linked resource in the question) is still valid for links in answers, and vice versa. I find it relevant for that reason. –  kiamlaluno Jun 19 '11 at 14:29
    
Your statement above, as in your first response, ignores the specific scenario outlined here. You make the incorrect assumption that I was only putting in a link to long code: in my answer (long) I included a list of steps to code an alternative solution for a question; as I said, I believe the questioner is at a level where they can immediately see what code is required to implement those steps. –  BillW Jun 19 '11 at 23:10
    
@BillW I am replying to what you wrote in your question; I am saying that, rather than giving a long answer and then a link to an external repository, it is better to report parts of the code together the answer. Five users think I am correct; feel free not to read what I write. –  kiamlaluno Jun 20 '11 at 0:04

What people sometimes forget is that Stack Overflow questions and answers are there not just to solve the OP's current problem at hand, it's intended as a repository of knowledge for other users of the site encountering similar problems.

The problem with linking to a dropbox or any other external resource is that they suffer from link rot leaving questions and answers pretty much useless for future users of the site.

If the code snippet is very large then sometimes there is no other alternative, however a public pastebin is probably more preferable over your dropbox. Personal websites and dropboxes are probably the most volatile places to drop code samples.

Answers that are along the lines of "Here, this will solve your problem" + link tend to be flagged and/or downvoted.

Similarly, questions that solely use external resources to provide code examples with pretty much no information tend to get flagged and closed as "Too localised".

The bottom line is that in your answer you should always describe what the code does in some reasonable detail, how and why it solves the OP's problem and ideally quote relevant snippets of code from your larger example in your answer.

This way we at least get the gist of the solution should your external resource "go away".

share|improve this answer
    
Hi, I'm well aware of the value of included code on StackOverFlow! By the way, I've never heard of a "public pastebin" before, but I see your point about the possible 'volatility' of DropBox. In this case my answer is already long, and contains an outline of a proposed strategy for coding a solution which I believe could be followed easily by the person asking the question. So, I see including the code as an optional "bonus," and, because it's long, think the answer is clearer without it. thanks, Bill –  BillW Jun 19 '11 at 14:11
    
@BillW what I meant by public pastebin are commonly used sites such as pastebin, pastie, gists(?) etc. As opposed to dropping on your personal website, blog or dropbox. I wouldn't class code snippets as "bonus". If a code snippet is likely to add value and improve understanding then include it. Three or four lines of code can say far more sometimes than two paragraphs of text. But you know this already. –  The Anti-Santa Jun 19 '11 at 14:25
    
What I'm not posting is a complete, long, demonstration of a solution using an alternative architecture than one used in the original question ... not snippets. If the person asking the question shows no sign of response to multiple other answers, and 'sticks' to what you see is a flawed architecture, then I think it's inappropriate to include a long code example demonstrating what you think is better architecture. Thanks for the pointer on PasteBin. I'm not linking to the question here because I don't want to embarass someone who may be having real difficulty in communicating in English. –  BillW Jun 19 '11 at 23:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .