1

How I Came Up with this Question?

Is it a good way to post the whole code, the whole project in a question? I see new users or even many old ones posting the whole code and ask to point out where the error is or what needs to be added or deleted from the code.

It is just in every one-tenth of questions that whole project is not posted. This isn't easy to read or understand. The person's mind just gets blown.

The user should post fair amount of code. I know posting code is a must for us to know where the error is but pointing out where the error is makes it easy and understandable. I have noticed questions (easy or tough) with lesser code get more attention and more answers and votes.

It also doesn't look safe posting whole of the code. It has chances of being stolen.

My Doubt

  • Should we post the whole code instead of some part which has to do something with the question?
  • Is it safe posting whole of the code?
3
  • 5
    You shouldn't post either the whole project or a snippet of the project; you should post a simplified complete program that replicates the issue and nothing else Mar 17 '14 at 11:17
  • @RichardTingle I agree with you and the doubt is cleared. Hah! But who would tell the users who do this? They see the how to ask page just as terms and conditions. Mar 17 '14 at 11:27
  • Shouldn't this be on SO meta, not main meta?
    – JohnP
    Jan 8 '19 at 18:58
5

"Safe" really depends on the situation. If this is code that you have written as part of your job then you need to discuss with your employer whether you are allowed to post the code. In any case, passwords and unique tokens used for security or authentication (or any other sensitive information) should always be replaced with placeholders.

An entire project should never be posted in a question. Code provided in a post should be the minimal amount needed to recreate the problem.

This issue is mentioned in the Help Center under the How to ask section:

Help others reproduce the problem

Not all questions benefit from including code. But if your problem is with code you've written, you should include some. But don't just copy in your entire program! Not only is this likely to get you in trouble if you're posting your employer's code, it likely includes a lot of irrelevant details that readers will need to ignore when trying to reproduce the problem. Here are some guidelines:

That bold text is not mine - this is how it actually appears in the Help center.

2
  • I agree with you and the doubt is cleared. Hah! But who would tell the users who do this? They see the how to ask page just as terms and conditions. Mar 17 '14 at 11:26
  • 2
    @KashishArora - the fact that users don't read what is right in front of them is a different issue :P The only people who can really make sure all users know this are people like you and me. People who know what needs to be done and why. It's our job as more experienced Stack Overflow users to help educate newer users and nudge them in the right direction.
    – Lix
    Mar 17 '14 at 11:28

You must log in to answer this question.

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