1

This is somewhat of a dilemma which I have come across on numerous occasion regarding: Minimal, Complete and Verifiable which states

  • Use as little code as possible that still produces the same problem
  • Provide all parts needed to reproduce the problem
  • Test the code you're about to provide to make sure it reproduces the problem

When writing a question of a more complex nature, some of the code required to reproduce the problem in a copy/paste manner may include many constants as defined, as well as other use cases which demonstrate working examples where the problem does not exist.

I believe firmly in providing in as concise manner as possible all relevant information in order to be able to obtain an answer which is more directly related to the problem I am having, however sometimes showing cases where something may be working inclusive as part of the question showing the case where I am having the problem, requires more than an extremely simplified rendition of the problem which would leave it open to speculation of probable cause rather than actual cause.

While I do my best to shrink and simplify, my coding ethic already does that for me where when I do have a problem, the simplest form usually requires little or no further modification to offer it up for demonstration of the issue.

My problem, is this:

How much is too much code?

and

If a class can show relevant cases of both working and non-working examples, is it okay to include the functional portions to demonstrate both working knowledge of the problem at hand, and to offer a test bed where-by someone answering the question may easily check those cases to compare for anything missed?

The other problem, is that some of the methods I work with, don't have working examples online which reference all the necessary constants or API declarations. Given that there could be (theoretically) a problem with any part of that which may be the source of the problem, is that also okay to include if I feel it is relevant to fulfill the complete portion, or should I exclude that and leave those answering to just assume that all my ducks are in a row with that stuff?

1
  • Shoot as low as possible, and if people need more to answer, they'll tell you.
    – user1228
    Aug 8, 2016 at 15:05

1 Answer 1

1

My rule of thumb when I look at posts: if there is horizontal or vertical scroll bar in the main sample then it is too much code.

Suggestions to make code at least look MCVE:

  • No scroll bars. Remove or possibly re-format code
  • Missing or separate constants - inline all values that can be inlined.
  • Unrelated comments and unused code - delete
  • Long descriptive identifiers related to your project - rename to short descriptive general names (i.e. customerFromDbAwaitingPasswrodVerification -> user )

For "why this code does not work" type of question - avoid correctly working code as main sample. Correspondingly don't post incorrect/non-working sample for all other types of questions (make it faster, better algorithm, design explanation,...).

Having second sample that shows more real/more complete code and test cases is fine inline in the post (at the end). Alternatively add it as link to public versioned or otherwise immutable location. Pretty much every language now has one or more "online compiler" sites that have fork functionality - working sample there is good option.

4
  • The other dilemma, is self-preserving data. If the entire issue can not be self-contained without linking to classes/etc (link rot), this becomes an issue of a different sort at a later date. Mostly, I can truncate code to minimal or no scroll, but on occasion, the code required to reproduce can extend well beyond even the 30,000 char limit, forcing me to put it elsewhere and link it, leaving it subject to link rot. I have removed block comments from some posts to try and squeeze it all in. (and naturally, i use minimal naming convention for descriptive functions/variables like getUser() ) Aug 9, 2016 at 9:27
  • 1
    "the code required to reproduce can extend well beyond even the 30,000 char limit" - Then you need to isolate the issue.
    – Cerbrus
    Aug 17, 2016 at 6:28
  • @SamuelJackson SO is just not the right place for such questions - there is no value of it for future visitors as no one would be able to evaluate match to they problem if you need to look through 30K of code/data to see that. Proper action on such post would be downvote as "not useful" and/or close as "...problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." Aug 17, 2016 at 16:28
  • So what you are saying is that if the simplest form of a problem to accurately reproduce it contains a scrollbar, then it is not something worth troubleshooting or having in the StackOverflow archives ? That StackOverflow is for problems only when they are of a trivial nature, or can be trivialized ? Aug 17, 2016 at 19:17

You must log in to answer this question.

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