What's our opinion on "give me the code" questions?

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.


Overview

There'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" questions

Suppose 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" questions

As 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?

2 Likes

The real problem is duplicates. The website will inevitably have some very simple questions with mass amounts of up votes on answers.

It’s easy to point out duplicates as the reason for closing a question. Don’t close it as “need more context” or “no research effort”, since the question is already a duplicate.

Both your example questions are duplicates. We shouldn’t have a whole bunch of duplicate questions & duplicate questions should not be answered.
Judging by the comments on the regexp question it’s possible the user didn’t need regexp at all.

We’re not building a better Stackoverflow here.

We’re creating the software.
Rules like that are up to the communities that use the software.

6 Likes

There are also “homework questions that can be real questions” and “homework questions that are pure homework”.

“Can someone tell me how to make a web page with a red background and text centered at the top and a form with 2 text fields and three buttons ‘Save’, ‘Cancel’, ‘Reset’ at the bottom” is (a) homework and (b) unless they present a reasonable initial effort at coding, going to likely be closed based on not providing code showing reasonable effort.

“Can someone tell me how to create a regex that validates a filename with alphanumerics and - and _ characters” can easily be homework (in which case the best answer for the student to actually learn is to point them to a regex explanation page and not to simply spit out the code for them) but can almost as easily be a real coding question. But once it has been answered the first time, any future questions on the exact same thing are duplicates.

1 Like

As @raphaelschmitz said - we’re using this forum to discuss how to make the software, not what questions to accept or other site policies - that’s up to individual communities.

8 Likes