Minimal Complete Correct Example
- Minimal - Make it as short as practical.
- Complete - Include everything a person might need to recreate the problem.
- Correct - Validate the separate parts. Use the naming conventions and code indentation your audience expects.
- Example - Provides an actual example of the problem.
Minimal
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.
Complete
If the problem requires some server-side code as well as an XML based configuration file, include them both. If a web page problem requires HTML, some JavaScript & a stylesheet, include all 3.
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.
Correct
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. Use the accepted naming conventions of that language for the same reason & use meaningful variable names. nameOfPerson
is a lot more clear than n
, and helps others keep track of what is going on.
Example
Ensure to the best of your ability that the MCCE actually reproduces the problem! Sometimes a problem might be fixed in the course of your changes, but for lack of a server restart or browser refresh, you do not see it work.
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.
That is my first thoughts on reducing the concept down to 'about a screen full' of text. The only reservation I have of it, is that ideally I'd like to have each letter different, so alternate words for one of 'minimal' (which I like a lot) or 'correct' would be welcome.
Thoughts?
In retrospect, I have decided that the following should not be included.
..& use meaningful variable names. nameOfPerson
is a lot more clear than n
, and helps others keep track of what is going on.
The two primary reasons for this are:
- I have seen many problems around SO which have text like "Say I have interface
A
which is implemented by classes B
and C
..". If the person knows how to abstract a problem, it might be solved within minutes. I don't want to exclude those types of codes from being considered as 'the rest of the abbreviation'.
- Many people speak English as a 2nd (3rd or 4th) language. Asking them to put 'meaningful' names might be embarrassing to them. (It never ceases to make me cringe when people feel the need to apologize for their English, mostly because of the many, many times I have received a great solution from people who speak 'my' language about as well as I speak their native tongue (I only know how to speak English). Further, I've managed to solve many problems where the class and member names are obviously not written in English, yet the problem is obvious.
So on the occasions (and there are not many of them) where we need more meaningful member names, it is not too hard to ask WTE:
Can you make a 'best effort' to translate/change that to more meaningful names? It might help me to understand & solve the problem. Don't worry too much if they are spelled wrong.
Or something like that.
In any case, by losing that part, we then have the 'space' to cover 'logical and consistent code indent'. Which I forgot to mention in this version, and is much more important. I.E. Some compiler errors are caused by misplaced 'end of code block' closing brackets, and a misplaced bracket might change the flow of the program, causing the bug.
It is much more important to focus on those. Plus, most IDEs have a shortcut to format code, it would not hurt to push that ability - it can save programmers a great deal of time and stress.
I will leave this version here, in case other people feel it is better then my new 'preferred version'. We can 'let the votes slug it out' as to which version is better, and if either version is 'best' of the many proposed ideas.
</shamelessPlug>