I have an issue that I detailed with code pastes on http://gist.github.com.
Would it be okay to provide a written description and link to the code pastes, or should I paste them in my question body instead?
Meta Stack Exchange is a question and answer site for meta-discussion of the Stack Exchange family of Q&A websites. It only takes a minute to sign up.Sign up to join this community
I would post all (relevant!) code in the question body, for at least two reasons:
Ideally, you should be able to illustrate your problem with the very least possible amount of code. Then I would say that it is best to include the code in-line with your question.
But, if you absolutely cannot be brief in your code samples then, sure, go ahead and link to an external source. But it will greatly decrease the number/quality of responses to your question. Few people will want to go off-site to trudge through large bodies of someone else's code and it becomes more difficult to discuss it back on the Stack Overflow.
It can work in certain cases.
First, you should do your best to pare your code down to the absolute most relevant bits on SO. Posting giant "wall o' code" questions (or answers for that matter) is discouraged for what I hope are obvious reasons.
Realize that you're asking other people to help you, so if you can help them by making your question as clear, short, and concise as possible, you're more likely to get good answers!
If you feel you absolutely can't pare the code down, and if answerers need to see more of the code, you can provide a [read more..] type of link to a pastebin or pastie or gist or whatever if someone absolutely must see the full, giant code attached to it.
While I always include all the relevant code to answer a question, comments are limited. In that case, a paste service can be an asset, but I would still avoid it if reasonably possible.
My current favorite is codepad.org. It has a clean interface, allows for forks and comments, executes a variety of languages in a sandbox, and will save pastes indefinitely—if you create an account and choose to permanently save.
I find execution especially helpful to demonstrate, confident you didn't make a
stupid mistaketrivial error. This is true even for broken code if you want to show the error message. Though I rarely point it out, the confused beginner should be able to discover they can edit and re-execute the paste without having to deal with their local environment.
StackOverflow doesn't provide the functionality that gist.github provides. What's wrong with using gists? Gists provides the ability to revision control the paste -- each poster can make edits and pull from previous versions, fork, etc. This is valuable. Moreover, and impressive -- they don't even need git installed to do it through the web interface.
Maybe SO can license the technology?