78

I've been seeing more and more frequently what I call "explain how this works" questions. A good example is: https://stackoverflow.com/questions/23523344/function-explanation-needed

Essentially, OP posts a block of code they either found somewhere on the net or some legacy code they don't understand, and asks us to tell them exactly what it does. This feels off-topic, but I am not sure how to handle it.

Are these types of questions valid? If not, what's the recommended flag / other course of action?

10
  • 12
    "Too broad" seems to be the proper fit for this. Too many possible answers on what that code could be doing.
    – Taryn Mod
    Commented May 7, 2014 at 16:38
  • 5
    Admittedly some of these actually do work out quite well: stackoverflow.com/questions/7202157/why-is-10
    – Mysticial
    Commented May 7, 2014 at 16:41
  • 3
    @Mysticial Well, that question doesn't look like it's particularly useful, just entertaining.
    – Servy
    Commented May 7, 2014 at 16:42
  • 12
    @Mysticial - I think my post and your post are worlds apart. Yours is a weird quirk, mine is "I'm too lazy to work to understand this block of code, someone do it for me" Commented May 7, 2014 at 16:43
  • I'd just downvote these questions on the grounds of not having done enough homework before asking and move on (unless it happens to be an interesting/unusual piece of code)
    – Mahn
    Commented May 7, 2014 at 16:45
  • 5
    99.9% of the time it's Too Broad (or Unclear What You're Asking, I guess), but there are exceptions to every rule: stackoverflow.com/questions/23033219/…
    – roippi
    Commented May 7, 2014 at 16:49
  • @pennstatephil I have certainly in my earlier days encountered code that made use of the some difficult to google language constructs or patterns(i.e. I have never seen the pattern before, therefore don't know what it is called, therefore can't look it up). Sometimes there is no amount of "work to understand" that can be done without someone else's help. In the days before help forums one would simply would have to give up and eventually revisit it when they happened to have coincidentally come across article about that pattern. Some of these may be poor effort, but don't make that assumption
    – AaronLS
    Commented May 12, 2014 at 15:12
  • 1
    @AaronLS you have over 10k rep so you can view the deleted question that was referenced, I believe. This was a very basic block of code, as was called out in the comments. There was no complexity to it. I have no problem with legitimately difficult questions (like mystical's example) but again, this was just flat out lazy. Commented May 12, 2014 at 15:15
  • 1
    @pennstatephil Agreed, just wanted to make sure wasn't an overly generalized opinion.
    – AaronLS
    Commented May 12, 2014 at 15:30
  • see also: How to ask “how to understand some code” questions
    – gnat
    Commented Jul 23, 2015 at 13:32

2 Answers 2

88

Such questions are almost always "Too Broad". Without a question that is more specific as to what should be explained, what is unclear, and what is already understood about the code snippet the possible information to be included in an answer is almost always going to be way more than is acceptable for this site.

Rather than having people try to guess at what, specifically, someone doesn't understand, what they want to hear more about, and what they already know, it's important that that all be included in the question. These questions are actually often salvageable, as the author often does have the ability to focus the question to what they are interested in, once they know that they need to do so.

2
  • 3
    Agreed. Too Broad.
    – Robert Harvey Mod
    Commented May 7, 2014 at 16:45
  • 11
    +1. Without any indication of what the specific point of confusion is, the only possible answer is basically the entire language specification plus documentation for any and all standard libraries. Not particularly useful, and pretty much the definition of "Too Broad". Commented May 8, 2014 at 15:14
20

You can also just comment:

Please don't post live-code examples on Stack Overflow. Instead, re-write a self-containing and reduced code example from scratch that reproduces exactly the problem you want to ask about. Everything else is too broad. Also restrain from debugging requests and personal tutoring requests here on Stack Overflow. All you need to do is to formulate a concrete programming question, that's your entry-card.

Then down-vote, close-vote (too broad maybe, but actually typo is a good bet, too :)), then open the user's profile in a new tab, order their questions by newest, check the last questions if those are dupes of the same debugging session, comment and vote the next one, too.

If you find that next one to be a duplicate or related (e.g. only got a non-helpful answer that triggered just the next question), flag the question for moderator attention as well.

1
  • 3
    As far as I can tell, while MREs are preferred, I can't find any official policy against live-code examples, as long as they are appropriately scoped. So I don't feel like I would have a basis for commenting like this. Commented May 13, 2022 at 19:01

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