-6

Just in case new users read the help center and the famous MCVE page, it would be nice to add one more recommendation, for instance in the "Complete" section:

Make sure all information necessary to reproduce the problem is included:
Some people might be prepared to load the parts up, and actually try them to test the answer they're about to post.
The problem might not be in the part you suspect it is, but another part entirely.

What seems obvious to some, but isn't obvious to others, given the questions I read those last months, is that you shouldn't post interactive code.

Interactive code starts by (Python):

age = input("What's your age")

So depending on what you input, the rest of the code behaves differently. In that case, if OP had entered

age = 12

he/she could have avoided the infamous Python 3 "input now returns strings" classical ultradupe issue.

The same goes for all those scanf questions (turning the scanf into hardcoded assignment would sometimes just solve the issue, which was with scanf in the first place)

I would add another part like (sorry for bad English :))

Unless it is crucial to the question, when writing your reproducer, make sure that it's not interactive. Get rid of statements asking for input, and replace them by values you're usually enter, and which trigger the problem you're witnessing

Of course that won't help newcomers who don't read the manual, but would make others realize that an interaction with the keyboard is bad in a so-called representative piece of code.

Extending the recommendation would be to advise users to hardcode the contents of their input files (unless the issue is I/O related) to avoid forcing potential answerers to create such a file on their disk (also preventing them to run/showcase the solution on some on-line platforms), but maybe that would be asking too much for the moment.

6
  • That only works if the problem is not in the interactive part itself.
    – BDL
    Commented Mar 10, 2018 at 13:09
  • I realize that. Edited the "advice" Commented Mar 10, 2018 at 13:10
  • 1
    Your suggestion is more debugging advice than advice for how to ask questions. In your examples, the problem was with the interactive part, thus posting it without the interactive part would make us unable to solve the problem (since we miss the part that causes the error). An answer should be both minimal and complete. That means the OP should check if handling an input is relevant, and if it is, he should include both the interactive code and the input that causes the error imo.
    – Erik A
    Commented Mar 10, 2018 at 16:11
  • 3
    8 downvotes. I'm taking that for a "no way, José", then Commented Mar 10, 2018 at 17:51
  • 1
    In my opinion, it is not just debugging advice. Yes, it might help the person debug, but creating a MCVE in general is helpful in debugging something as you are likely to find the bug as you cut away the parts that aren't necessary for reproducing the bug. If they cut it out and it solves their problem, great! Now they either: a) don't need us, or b) can ask a better question knowing that the problem is in their user input methodology. If cutting it out doesn't solve their problem, then it is one less avenue we have to comb through to find the bug and it streamlines the testing process. Commented Aug 14, 2018 at 19:57
  • I'm going to specifically call this out. scanf() stuff doing the wrong thing is a pretty common question type here that's rather dupe happy but the noobs who are posting the questions already know the issue is at scanf() and don't know how to get any farther.
    – Joshua
    Commented Nov 13, 2018 at 3:46

1 Answer 1

13

Interactive is one part. But I think the root of the problem is, that people do not understand what minimal means.

I have seen a good example by CodeCaster:

For example in the C# and LINQ tags, a lot of questions are asked about processing a collection of data. These generally come from a database or text file. But the database and text file are not relevant to the problem. Nor is the fact that the code runs in an event handler, or in a Web API Action Method, or in a Windows Service.

So in my opinion we should work on better explaining what minimal actually means. My English is not good enough for a suggestion.

You must log in to answer this question.

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