Without a Minimal, Complete, Verifiable Example, it is hard to know what is wrong
A question without any code, or where the code provided is not
- minimal – as little code as possible that still produces the same problem
- complete – contains all parts needed to reproduce the problem
- verifiable – would compile if run, and exhibits the problem described in the question cannot be easily, if at all, answered.
When a code sample has these qualities, it is generally referred to as an MCVE.
Why this is a problem
Without code, users will have to guess what might be wrong with a person’s code. With too much code, the problem may be lost like the proverbial needle in the haystack. If you post code that is lacking the section that actually exhibits the issue, then what is included is practically worthless. And, if the code is full of compile errors or artificial bugs caused by translation to the question, these may hide the actual problem.
Why this is worth a downvote
Without an MCVE included in a question, it is much harder to answer. This also means it is now much more unlikely the question will get an answer. Experienced users may be able to determine the problem, but it will take them longer than necessary to do so. Or, they may be reduced to guessing at possible reasons until they guess right, or give up. This is considered rude as it wastes the time of those trying to help.
Another huge benefit of an MCVE is that people can just copy paste the code and run it to observe it’s exact behavior. Many times when people help, they write code in order to help find a solution. Having an MCVE spares them the work of converting example code into an application that exhibits the problems described in the question.
What to do next
Create an MCVE! There are a number of tutorials available, some of which are part of larger “how to ask a good question” guides, such as this one (see the “Sample code and data” section). Read them! They are there to help you.
Once you have a good grasp of the concept, go back and edit your question. If you have too much code, clean it up! Remove everything that doesn’t have to do with the logic that the question asks about. For example, remove empty lines and comments, if not relevant to the question. If the code contains HTML markup, remove CSS and layout details that aren’t part of the question.
If you don’t have code, create a prototype that only covers exactly what your logic is trying to do. Make it as clean and simple as possible, and make sure it reproduces your error. You may be surprised to find out that you discover what your problem was by simply taking this step! But, if not, you can then use this prototype to add code to your question.
Leave a comment!
Once you have done this, leave a comment to the person who sent you this link. They will be happy to retract their downvote.
Did this page help you?
This website is here for everyone’s benefit, most importantly yours! If this did not help you, or if you would like to leave feedback, please create an issue regarding this page on GitHub, or submit an improvement directly.