3
\$\begingroup\$

On all Stack Exchange sites, you can't post answers or questions that are mostly code. You always have to include some text minimum, otherwise you can't post the question.

I do understand why this is very helpful on Stack Overflow, but why is there this text minimum also on Code Review?

Code Review is a site for code to be reviewed. That's why you usually have to post much code. With this minimum, users tend to add irrelevant information, e.g. this question is filled with personal data of the user, such as the age, to reach the text minimum.

\$\endgroup\$
  • \$\begingroup\$ Because "here, review this code dump" is a bit rude, isn't it? Take the time to present your code to reviewers instead - reception will be quite different. \$\endgroup\$ – Mathieu Guindon Jul 22 '17 at 1:46
  • 2
    \$\begingroup\$ On that specific Hangman question that you cited, the author voluntarily included a lot of introductory text, way more than the required minimum. Look at the revision history — I actually had to significantly reduce the verbosity! \$\endgroup\$ – 200_success Jul 22 '17 at 2:00
  • 1
    \$\begingroup\$ I tried to edit the post by reducing the introductory text to contain just the reason for the question without any biographical information, but I couldn't change anything because of the text minimum. \$\endgroup\$ – Erich Jul 22 '17 at 6:10
9
\$\begingroup\$

Questions and answers that consist of code and no supplementary explanation are colloquially known as "code dumps", and are generally not appreciated on this site. The minimum text requirement is an important quality filter, and you must not try to circumvent it (as some users have tried to do, by including some garbage text).

For answers, the reason for the text requirement is straightforward. Since this site exists primarily to provide suggestions to help programmers improve their coding skills, answers must state some insight about the code being reviewed. In general, the text is mandatory; including code in an answer is optional. Think of it as a log message when committing code to a version control system. Checking in code with no explanation is just not professional — you should say something about what you changed and why. (One rare exception: the "oh, duh!" rule. If your proposed solution is self-explanatory and obviously The Only Conceivable Right Solution, then the code alone might suffice.)

For questions, you really ought to include sufficient context for the code to be reviewed. Context might include:

  • An explanation of the task that the code intends to accomplish, ideally including sample input and output.
  • Is it a ? If so, please cite the source as well as summarizing the task. Is it an ? In that case, how much time were you given, and what resources did you have available to you?
  • Why did you write this code? For work? For learning? For fun? To reimplement a feature from another language?
  • If the code is part of a larger system, tell us about the components that use this code.
  • If it is an query, tell us about the relevant parts of the schema, what indexes exist, and any tables that might be exceptionally large.
  • State any concerns that prompted you to post the code: performance, security, scalability, readability, simplicity, flexibility, internationalization, …. If your concern is speed, do you have any benchmarks or performance targets?
  • Conversely, list any criteria that aren't important to you. (For example, the input might be already validated, and known to be short, trustworthy, and purely ASCII.)
  • What flexibility do you have? What alternatives have you considered? (For example, why did you pick this language, and are you open to the idea of switching to a completely different tool if it works better?)
  • How much experience do you have with the language? Are you open to using fancy language features, or do you want to try to keep it simple?

Those explanations can significantly affect how reviewers perceive your code, so code-dump questions are generally not acceptable.

In a few very rare circumstances, where the task is well known to everyone, the title alone might suffice to describe the code (e.g. "Base64 decoder in C"). But even then, if you post a question with no contextual remarks at all, I wouldn't be surprised if you get heckled and downvoted for it.

\$\endgroup\$

You must log in to answer this question.

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