48

On a question asking for an approach to solving a programming problem such as this one the user is not asking it as a "gimme teh codez" (as far as I interpret it). So I don't interpret it as being too broad. Maybe that's their hope, but I've been able to effectively help people without writing specific implementations. They are asking for suggested implementation approach, which can be solved with a conceptual/pseudo code description.

For example an answer might be:

All clickable controls have an IClickable interface, thus you can use a feature detection approach such as:

IClickable clickable = newControl as IClickable;
if(clickable != null)
  clickable.OnClick += generateWaveOnClick; // wire up to global handle

Your implementation of generateWaveOnClick will have a reference to the control being clicked, and need to access the graphics object of the control and manually paint the wave. The specifics of custom rendering are too vast to get into all the possible details, but there's plenty of questions and tutorials that deal with this.

Now I know little about WPF so this is a bit of a fantasy answer, but from my experience with Winforms I imagine there's a viable "feature detection" approach. Point being is that you don't have to write an entire implementation to answer such a question. While one might argue there is "not just one answer that solves the problem", it is rare that a question on SO has just one valid answer. Often there are many valid approaches and some fit certain scenarios better than others. It's kind of like trying to say there's only one way you can solve a math problem.

This person may simply not be aware of various "feature detection" techniques that take the approach of reflecting upon objects to see if they have certain properties/events available. It's a bit of a reverse search problem to say they did too little research, as they simply are unaware of what concept they should research.

A commenter states there is a code requirement. I have seen this cited before, but am wondering if this is an official requirement. I've certainly asked questions that don't involve code at all, but

Is there really such a requirement for an asker to show some code? Obviously if they have a very specific code related issue, this makes sense, but I don't see it as a universal requirement.

Take this fairly well received question I asked, that was an attempt to gain a better understanding of the mechanics of a language feature. I had read many articles but most only covered the basics and I didn't make the connection of how behaviors of things like serializers interact with attributes. The question dealt specifically with a programming topic, I tried to make it fairly focused so that an answer wouldn't need to be a huge tutorial on attributes, yet the question did not deal with a programming problem. I don't see how SO's criteria requires there to always be a problem statement nor a specific set of code. Certainly that helps frame a question better, but I think there are plenty of questions without code that are focused enough and are on-topic for programming QA such that they meet SO's criteria.

Now maybe the close voters didn't vote due to lack of code, but simply felt it was too broad, as they interpreted it as a "write the code for me" question.

  • I tend to feel there's room to interpret the question as a "give me an approach".
  • Answer as such, with a succinct "general approach" answer.
  • Let the community reward good succinct answers.
  • Leave the asker two choices:
    • take the conceptual information in that answer and go off to write their own code,
    • be a baby and complain that they wanted complete code.
  • Answerer gets community upvotes, and maybe one downvote from asker.
  • The answerer still comes out on top with a net positive.
  • The answer is still a useful resource to others.

Sometimes, especially programmers delving into an unfamiliar technology area, are faced with many non-standard tutorials. There's alot of stuff I see on CodeProject that is absolutely not the way you'd see it done in a production environment. There's not the same level of critique on blogs/interwebs as there is on SO. My first instinct is to wonder, "What approach to this problem would someone more experienced take?"

I'd almost rather help get someone started off on the right foot, rather than them cludge together a really bad approach. Rather than them blindly cludge together a solution and piece meal ask for little hackish fixes here and there, rather than address the larger design problem.

What does the community think?

Note: I've certainly cast my own "too broad" votes on questions asking for things like "an implementation of a binary tree sort". Obviously they are aware the algorithm exists(which essentially covers the general "approach"), and so that doesn't leave much but to write the code implementing that algorithm. In such an obvious case I vote "too broad" and explain that it would be too vast of an answer to write a full/complete implementation of the algorithm.

4
  • I think that question is fine. As a beginner its often not possible to write the code if you dont know where to start, or even if something is possible. Voted to reopen the question. Commented Apr 25, 2015 at 15:04
  • I'm honestly tempted to go to your question now and tell you that you need to provide what you did and why that failed. Am I a bad person?
    – Nic
    Commented Apr 25, 2015 at 15:05
  • 5
    What is the actual question? What he wants to do is crystal-clear, never that hard with a UI gadget. But what's the problem? Don't know how to apply a storyboard? Can't get the animation started at the mouse position? Trouble getting it clipped to the control? Don't know how to write the control template? Looks poorly on some controls? With the snippet it is now clear, he has no clue how to get started. It is a task, not a question. Commented Apr 26, 2015 at 7:41
  • 1
    Some questions are unanswerable without code. Those have a close reason. Some are unclear without code - that has a close reason too. And some are just lazy, which is a reason to downvote. But generally - code isn't mandatory in all questions. Just where it's important/relevant to the problem at hand. (As an illustration if nothing else).
    – Sobrique
    Commented Apr 26, 2015 at 12:07

2 Answers 2

49

You already answered the question.

"I think there are plenty of questions without code that are focused enough and are on-topic for programming QA such that they meet SO's criteria"

If the asker's intent is clear, they have sufficiently described the problem, and the problem is in-scope and on-topic, the question should remain open. No code required.

Additionally, if the user showed research effort, the question is clear and useful, etc, they should even be upvoted. Again, No code required.


However the clearest, most practical way to explain a programming problem is to, well, show some code. Unquestionably you can write a question without code that would meet our standards, but code nearly always clarifies what the heck the OP is talking about, automatically shows expected input, etc. Code is nearly always an improvement to a question, and very few users are capable of writing an even decent question without it.

So no, its not a requirement. That said, if you don't have it, I'm worried for that post from the get-go.

14
  • 3
    "Clearest"? I doubt that. "Most practical"? Absolutely.
    – Makoto
    Commented Apr 24, 2015 at 22:58
  • 6
    @Makoto Code is worth a thousand words many times. So to me, yes, its clearer (well, new users code takes some parsing, but its still usually better than their descriptions/english). Commented Apr 24, 2015 at 23:00
  • 1
    I take umbrage to that sentiment. A user speaks far better in their native language than they do in code. Articulating an issue/solution is half of the work anyway; if they can articulate it clearly enough, then the code becomes straightforward.
    – Makoto
    Commented Apr 24, 2015 at 23:02
  • 3
    @Makoto They speak better, sure, but its pretty darn obvious what they intended to do when they show the code they used to try and do it. Don't get me wrong, just code is worse than none at all. That said, code almost always helps clarify a question for me. We can agree to disagree of course. Commented Apr 24, 2015 at 23:04
  • 1
    I think we'll have to agree to disagree, then. I've worked with and tutored people who wrote very confusing (but straightforward to solve) code, when it turned out that their problem didn't call for that code at all. It happens, and it's very common; I wouldn't want to believe that code is unambiguous as to what problem a person is attempting to solve.
    – Makoto
    Commented Apr 24, 2015 at 23:31
  • 1
    @Makoto Which is why code-only questions are the worst :) Commented Apr 24, 2015 at 23:33
  • 2
    @Makoto: Unfortunately, not everyone has English as their native language. That's why "gimme teh codez" is such a significant problem.
    – BoltClock Mod
    Commented Apr 25, 2015 at 4:17
  • 1
    I will often throw 'show some code' comments when it looks like someone hasn't bothered to research the problem or even try themselves. Code is generally useful for both illustrating the problem and showing some effort at solving it already. That doesn't mean it's always a requirement though. As noted - there's quite a few really good questions - and answers - that have no code in them at all.
    – Sobrique
    Commented Apr 26, 2015 at 12:05
  • No, but a reference implementation, ANY reference implementation, can often be useful in furthering the user's desire; it may be all they need is throwaway so they can test SOME OTHER SYSTEM. joelonsoftware.com/items/2008/03/17.html Commented Apr 27, 2015 at 14:10
  • Yes, certainly sometimes even pseudo code that tries to represent what the user's desire is can be useful. Programming languages are often significantly less ambiguous than any human language. So I think it's great to encourage code where appropriate, but some users take insistence of that to an unhealthy extreme.
    – AaronLS
    Commented Apr 27, 2015 at 15:25
  • Broken code is a bad substitute for the problem statement (example input, output, clear intent). Existing code may have issues unrelated to the actual problem. Often If OP were capable of expressing the problem using code there wouldn't be the question in the first place. Code is a useful addition to a question; it shouldn't replace the question itself.
    – jfs
    Commented Oct 11, 2015 at 10:16
  • This needs to be reworded if it is going to be the target of duplicate closures for this topic in general. There may not be a universal code requirement, but simply defining the problem, the situation, and the scope is not enough to warrant both an upvote and an open question. Questions requesting implementation of features are should be closed as "too broad". Stack Overflow is not a job shop, and that is the picture painted here.
    – Travis J
    Commented Oct 12, 2015 at 22:19
  • 1
    @TravisJ: "too broad" does not mean what you think it means. You probably want this: Should we add a “Do my work for me” close reason?
    – jfs
    Commented Oct 13, 2015 at 9:12
  • @TravisJ Perhaps I should emphaisize it, but I do say the problem needs to be in-scope. This was intended to say "not too broad." If you feel it could be clearer, I'm happy to listen to any suggestions you may have. Commented Oct 13, 2015 at 18:18
8

Personally, I think the question in its original form was too broad.

Even if not a "give me teh codez", I always find "give me an approach" questions suspect. They may be trying not to look like they are asking for someone else to do their research for them.

At best, the answers to an "approach" question, if the requirement is not a de-facto standard in whatever programming context the question refers to, will probably not be precise and clear, since you don't actually know how much knowledge the asker is lacking. So, should you start from the very basics? From a high level approach?

I tend to either downvote such questions as not-well-researched, or vote to close them as too broad.

That being said, the asker made a good edit since then. It's not so much about the code he added as about explaining his own approach and where he finds it is lacking, which can help potential answerers understand his level of knowledge and point him in the right direction with a well-focused and concise answer.

In short:

  • I think it merited a "too-broad" closure in its original form.
  • I think the comment about the code requirement is dead wrong. I think the only code requirement implied by the SO help desk is for homework assignments.
  • I think a better comment would be one that would explain why the question is too broad and what improvements should be made, such as "please explain what your own approach would be, where you got stuck, or why you think your approach would not be the best one".
  • Perhaps the thumb rule for the asker should be: if you want to improve your code, put your code in the question. If you want to improve your approach, put your approach in the question. If you want other people to give you ready-made code or approach, don't ask on SO.

You must log in to answer this question.

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