I wanted to post my code in a question and it's at present, 90+ lines long. Is it ok to post the whole thing, or should I try and only post the most important pieces?

  • 1
    Cheers for asking first. – squillman Mar 3 '10 at 3:23

Most important parts only. We're here to solve problems that somebody else might have too, so get the problem down to its smallest subset before posting.

| improve this answer | |
  • Yea, though sometimes the problem is identifying the important parts. In such cases, usually there will be comments to ask for more information/other code portions. Sure beats sniffing through hundred lines of codes. – o.k.w Mar 3 '10 at 4:24

I would try to reduce it slightly, but there's significant value in posting a complete example if you possibly can.

I have an article I wrote on "short but complete examples" a while ago which I think still holds water. Basically take out everything that's definitely unrelated - particularly GUI and anything to do with files - so that the result is self-contained and short, but still clearly indicates what's going wrong.

This process often lets you find the problem yourself, admittedly :)

Having said all this, I would rather have a 100 line program which I can run and see failing than a 10 line snippet without enough context to diagnose the issue.

| improve this answer | |

On the technical side, there is no limit and it might even break the user's browser if there is too much code.

That being said, do not post too much code. Try to break it down to pinpoint the part that is linked to the problem. It will be easier to read, faster to load and will not scare people off.

| improve this answer | |

You must log in to answer this question.

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