For long code, what should I do?

  1. write down all the code in body content
  2. Parse the snippet and link the rest of it using pastebin
  3. post the pastebin URL only.

And, how long is long?


If you feel you need that much code to ask a question, the question is probably wrong. Or, at least, a bad fit for Stack Overflow.

| improve this answer | |
  • 2
    I can take conclusion that the better solution / question is, to give short snippet and post the long one on pastebin. – ariefbayu Nov 2 '09 at 6:47
  • yes, that is a good compromise -- show the relevant bits and put the rest behind a link. – Jeff Atwood Nov 2 '09 at 7:49

Ideally you should make it short enough to fit in the normal question length. I've yet to see a good reason for more than about 80 lines of source in a question on SO.

| improve this answer | |

You should keep the code to the minimum capable to explain your inquiry/problem.

In my experience, more than 100 lines is too much.

You should always try to post the smallest possible code showing the problem.

| improve this answer | |

It is better to just include the important lines in your code; however, sometimes you can't realize that other parts of the code are relevant too. So, in same cases is good to include the whole code. For that reason I think Stack Overflow should have the option to include an option to attach code in files, or maybe a pastebin like solution.

| improve this answer | |

You must log in to answer this question.

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