Long or incomplete programs

If you're reading this, it's probably because I asked you to produce a short but complete program which demonstrated your problem (as described here) and you failed to do so.

There's nothing personal about this page. I haven't written it because I don't like you, or because I think you're a bad programmer, or because your problem doesn't deserve my attention. It's just that in order for me (and others) to help you, it's worth you doing a bit of work yourself first.

If you've given a good reason why you can't come up with a short but complete program, of course, that's a different matter - sometimes they're almost impossible to come up with, because you can't reproduce the problem in the first place. However, far too often people reply to my request with code which is either horribly longwinded for no good reason, or won't compile, or is only part of the code. No, I don't want to start a new project in VS.NET just for the sake of your problem - it takes much longer to create a project, possibly add some controls in the designer, cut and paste your code into just the right place, find the problem, then delete both the project from the solution and the the files from the disk. I want to be able to cut and paste your code into a single text file (okay, it's sometimes necessary to have more than one file - especially if you're dealing with something like one assembly loading another), compile and run it from the command line, and then delete it from there if necessary. (Usually I just reuse the same file - this is easier to do than reusing a project).

Is my approach somewhat bossy? Yup. However, it gets results, and gets them faster than other approaches I've seen. So please, check this list, fix your code, and post it again - I promise I'll look at it if you do...

Is it short?
Have you removed everything you really don't need? Does your code really need to run in a GUI? (Hint: if your GUI consists of a single button which you click to do the real test, you can almost certainly rewrite it as a shorter and clearer console app.)
Is it complete?
Have you provided everything I (and others) need to get your test program working? There should be no need for others to create a skeleton round your code - the contents of a method is not the same as a complete program. In short, I should usually be able to copy and paste the relevant section of your post into a new text file, and hit compile, without any extra typing on my part.
Does it compile?
It's a good idea to try to compile your test program yourself with only the knowledge that the reader will have: cut and paste the code from the post you're about to make, and try to compile it. You may find that line breaks are a problem, in which case it'll help everyone if you try to fix that in your code. You may find that it requires extra parameters on the command line to compile properly, in which case it would be really helpful if you'd include the command line to compile it in the post. (Assume that people have run vsvars32.bat but nothing else.)
Does it demonstrate the problem?
Have you told us what to do with the program? If any user interaction or command line parameters are required, tell us. Also tell us what you'd like the program to do and what you're actually seeing on your screen too. If we don't know what you're expecting (and why, preferrably) it's hard to know what to look for - especially if the results are exactly what we'd expect.

If you really feel that the answer to all the above questions is "yes" then please feel free to ask me for clarification as to why I've pointed you at this page in the first place. Apologies in advance if I've missed something and everything was fine in the first place.


Back to the main page.