tl;dr:+ "Give me the code" questions are an opportunity to offer explanations of both good and bad solutions to help new users learn, since we can learn as much from what to do as we can from what not to do.
- “Give me the code” questions are far more frequently over-specific or homework-based, and it’s not worth the time to give 10 well thought out answers to a user who’ll just copy-paste the shortest one that works. Moderating them is also way more effort than it’s worth.
OverviewThere's always going to be users who're looking for a quick solution to homework without aiming to learn anything, and there's no doubt questions like that cause issues - when answered, at best, it's unlikely another user will glean anything from them, since they're very often too specific to be applicable elsewhere. That being said, what about questions that genuinely are seeking ways to perform a common action, or an action that one could reasonably assume will be applicable and helpful to others?
An argument for allowing "Give me the code" questionsSuppose a user asks, in good faith, how one would go about - say - increasing a variable from 1 to n. There's many options: for loops, while loops, do-while loops, recursion, GOTO, launching n parallel threads that increment a counter by 1 each as they return, just setting the variable to n without increments, throwing n exceptions and counting the number of times the log is written to, naively assuming an increment takes 1 second to complete and putting it in a loop that runs for n seconds, etc.
While a few of the above clearly aren’t viable to anyone with code experience, how many new users would be able to recognize the reasoning behind why the answer (or their question) is bad? What about why a given solution is good? We want them to learn, not program by cargo cult. An argument can be made that a good example with an explanation of why it’s good is as helpful as a bad example with an explanation about why it’s bad. I’m not sure if this counts as an edge case because I’ve seen examples of these questions on SO with very high scoring answers (all of which are also very old, so maybe this was before the practice was frowned upon?)
I’ve written a few answers to what could arguably be considered “Give me the code” style questions. I would by no means call myself an “expert” in these fields, but giving these users a chance to hear from the experts is something we can’t write off as untenable.
An argument against allowing "Give me the code" questionsAs nice as it would be to provide explanations and tutorials to users who ask these kind of questions, it's just not a viable possibility. Questions like these could reasonably be answered and indeed might be quite useful, but as a whole, the number of questions too specific to a single problem or directly copied from homework is far, far greater than the ones that would be otherwise useful. Even for the answerable questions, we can offer paragraph-length, properly cited explanations of why an elegant solution is effective or ineffective, but we can't stop a user from picking the inevitable 10-word answer with the lazy but functional solution.
What’s worse, this opens a slippery slope: if we’re willing to answer questions looking for generic solutions to generic problems, at what point can we define a question as “bad” or “too specific”? Moderators now have to wade into ambiguous waters, deciding which questions to allow and which to remove in an environment where objectively worse questions have already received many high quality answers. Overall, these questions are far more effort to answer and maintain than they’re worth.
I’ve answered a few “Give me the code” questions with detailed answers explaining why one approach is better than another - the questions themselves received negative scores, and the latter answer wasn’t even acknowledged by the user. I could’ve spent that time answering a better-posed question for a user who’s interested in learning, not looking for a quick-and-dirty solution.
What’s our stance on questions like these? Blanket disapproval, more leniency, or a case-by-case assessment?