#Minimal Complete Valid Example
- Minimal - Make it as short as practical.
- Complete - Include everything another person might need to recreate the problem.
- Valid - Validate the separate parts. Use the naming conventions and code indentation the audience expects.
- Example - It needs to show an actual example of the problem.
This can be done one of two ways.
- Restart from scratch - Adding in only what is needed to see the problem. This can be faster for vast systems where you think you already know the source of the problem.
- Divide and conquer - Where you have a reasonable amount of code, but the source of the problem is entirely unclear.
This is a good idea for two reasons:
- Some people might be prepared to load the parts up, and actually try them. The acid test of the changes they are about to suggest.
- The problem might not be in the part you suspect it is, but another part entirely.
Validate the HTML or XML. Run the code of a run-time problem through a compiler and check there are no compile-time errors.
Don't reduce code to a single line just to make it shorter! It is important that people who read it are able to understand what they are reading. Also ensure the code uses a logical and consistent code indentation. This helps both you and other people to see misplaced brackets that might change the code flow & cause bugs. Most code editors have a shortcut for formatting the code.
Ensure to the best of your ability that the MCVE actually reproduces the problem! Sometimes a problem might be fixed in the course of the changes, but for lack of a server restart or browser refresh, the fact that it is fixed is not obvious.
It might help to shut the system down and restart it, or transport the example to a fresh machine to confirm it really does provide an example of the problem.
OK - I am happier with this version over the earlier draft..