32

On occasion on SO, I've noticed that certain users like to post answers that may solve the problem, but intentionally do it with a methodology that's different from the one specified in the OP and/or its tags.

Examples:

Q: How do I do such-and-such in csh? Tags: [unix] [csh]

A: Don't use csh. [inserts link to blog that bashes csh]. In bash, you can do it easily by...

or

Q: How do I do such-and-such using GrigBagLayout? Tags: [java] [swing] [gridbaglayout]

A: GridBag sucks. [inserts link to blog that bashes GBL]. The only layout manager you should ever be using is MigLayout, and here's how to do it...

I feel that the proper procedure would be to ask the user, in a comment in the OP, if they are restricted to using technology X, and if they would consider using alternate technology Y. For all we know, technology Y:

  • may not be available on the user's system
  • is not allowed to be used for some reason or another that's out of the user's control
  • is disliked by the user

And, even if the OP is able to use technology Y, future visitors with the same question may not.

I feel that it takes away from the usefuleness of a Q&A site like SO. Users come to SO with a question, and search for the answer among similar questions using tags and keywords to help aid in the search. If the answers don't correlate to the tags and/or keywords in the OP, then finding answers becomes more difficult.

Let me be clear: If it happens once in a while, I don't think it's that big of a deal, and may actually be useful on occasion.

It's the serial offenders, who seem to hawk certain tags so thay can push their technology preferences, that kinda rubs me the wrong way. It almost feels like advertising, or that some agenda is being shoved down my throat.

We all know that there are several "holy wars" in the programming community (bracing style, perl vs. python, etc.). SO seems to make every effort to restrict this.

So, should I just turn a blind eye, or call them out on it (and if so, how)?

EDIT (for clarification of my question):

There are many useful/helpful answers and comments here that seem to address the general topic of:

"Is it okay to offer answer in a different technology from what is asked and/or tagged in the question?"

That's all well and good, but not really what I'm asking. Perhaps I haven't been clear about my question, which is a little more specific.

What I have an issue with are the posters who seemingly are hunting down topics or tags, with the sole purpose of boasting about their preferred technology, being sure to rail against the technology asked, and doing it over and over and over again.

There are times when I find myself saying, "hey, I think I remember this guy preaching the same thing in another thread." Then I look up answers from that user on the same topic and they pretty much don't seem to have the capacity to answer a question about X without railing against it and preaching about Y.

It's the whole "agenda thing" (see Steve Bennett's answer) that rubs me the wrong way.

Should I just ignore, or call them out on it?

12
  • 32
    JavaScript -> "Oh, don't bother trying to do that: just use jQuery!"
    – AstroCB
    Commented Aug 8, 2014 at 20:10
  • Looks like they don't answer the question. If they showed how to do it with the tech in question (or explained why it's not possible that way) as well, those could be decent answers, even better than an answer just showing how to do it as the OP asked. Commented Aug 8, 2014 at 20:15
  • I agree with your "proper procedure" of asking in a comment. I generally try to respect the technology choice of the OP. But if I feel like they might really be much better off with something else, I sometimes can't resist leaving a comment saying something like "Did you consider using ...? I think it would be much easier to solve your problem that way." But that's clearly not material for an answer, unless the OP responds back and says that they would like to hear in detail how to solve the problem with the proposed alternate approach. Commented Aug 8, 2014 at 21:17
  • 2
    I get frustrated when folks don't read the question or answer a different question (that was not asked). I flag the egregious and poorly written ones for what they are: "Not an answer" because they are not an answer to the question that was asked. Let the community decide what to do with it. I think its perfectly fine to offer as a comment, though.
    – jww
    Commented Aug 9, 2014 at 6:47
  • 1
    I for one found many answers by finding a parallel question asked and answered for a different language/api/technology , but with one of the additional answers specific to the language/stack that I am using. Deleting such 'gems' would do a great disservice to countless people looking for help. Splitting such an answer into a separate question/answer would be a better idea, but no, never delete.
    – NickNo
    Commented Aug 9, 2014 at 10:23
  • 3
  • I think the best thing to do (whether your goal is actual to improve the site, to hawk your own favorite technology), is to write an answer showing the best way to do it the way the OP wanted (or showing why it isn't possible), and then show how much easier it is with the other technology. Sometimes it's impossible to do that without way too much effort, or way too long of a post. But when it's doable, why not do it?
    – abarnert
    Commented Aug 11, 2014 at 2:29
  • 3
    Also, some such cases are clearly instances of the XY problem, and when that's true, isn't it better to solve X than to try to solve Y?
    – abarnert
    Commented Aug 11, 2014 at 2:31
  • Indeed. This is exactly what the XY problem describes. And actually the correct answer is "Dont do that" followed up by "Here's how you should do it". Sometimes a bad idea is a bad idea and people should be reminded as such. The only times where the XY problem is not an XY problem is when the OP specifies a reason for the restriction (for example writing a script on a router with only csh installed).
    – slebetman
    Commented Aug 11, 2014 at 3:24
  • It may be fair to say "javascript isn't the best language to use for this particular type of problem..." although the OP may not be in the situation to choose the language. Of course that isn't knocking Javascript just that it's being used in a situation where another language may be more suitable.
    – CashCow
    Commented Sep 8, 2014 at 14:49
  • Related: What is the best way to deal with toxic/unhelpful comments?, which is about comments suggesting that the asker's approach or chosen technology is flawed. I think Your Common Sense's answer applies equally well to this question: "You shouldn't be too selfish. Instead, always bear in mind that Stack Overflow is not your personal help desk but rather a knowledge base open to anyone." Commented Sep 9, 2014 at 21:14
  • My problem is when people provide a jQuery answer to a JavaScript problem, or a PDO answer to a MySQLi problem. My tags clearly indicate what technology I'm using but the responses apply to other technologies. Can I flag these?
    – Warwick
    Commented Dec 19, 2014 at 14:48

7 Answers 7

36

The help center says this about answering questions (emphasis mine)...

Answer the question

Read the question carefully. What, specifically, is the question asking for? Make sure your answer provides that – or a viable alternative. The answer can be “don’t do that”, but it should also include “try this instead”. Any answer that gets the asker going in the right direction is helpful, but do try to mention any limitations, assumptions or simplifications in your answer. Brevity is acceptable, but fuller explanations are better.

So, absolutely it's fine to do. It's common to see it where asker is using arrays, academic looking posts, and answers offer up a vector or ArrayList. I think unless explicitly stated in the question such and such must be used, anything's fair game. Part of why folks are here is to learn.

3
  • 4
    In particular, I think it is valid to suggests an alternative if the OP's question is based on bad programming practice. To just answer the question might help the OP, but not other readers. To propose an answer that suggests a better programming practice is therefore a very good thing, as it can teach other readers that the OP's method isn't something they should be using. Such alternative answers by an expert on the topic add a lot of "wiki" value to the site, even though they rarely become chosen as the accepted answer.
    – Lundin
    Commented Aug 11, 2014 at 7:03
  • I'd agree with that. I'm a bit of a question purist so I think if they ask for a specific solution in a valid question, which is the part I think you're referring to, you should give it if not only in a pseudo style. Then explaining why it's considered bad practice and better approaches would be great and definitely more beneficial in general. If nothing is explicitly requested then doing so is of course covered above. @Lundin Commented Aug 11, 2014 at 7:45
  • 1
    If I'm inclined to answer a question with an alternative to the requested solution flavor, I like to also answer it as posed, when possible, in the same answer. When I can do this, it tends to provide a strong basis for offering the alternative, yet still answers the question as posed in the event that my alternative is not viable for the OP. Commented Sep 9, 2015 at 19:52
20

Ultimately, your answer should help the OP, and people with the same problem as the OP get beyond the problem at hand.

When an answer suggests using a different technology, you should evaluate whether that's a feasible option for the OP. If it is, then its a legitimate answer. If it's not feasible and the answerer doesn't look like he's looking out for the OP's needs, then downvote.

Stack Overflow is about helping people. It's not a trivia game. Resolving the underlying problem is a lot more important than directly answering the question.

14
  • 7
    others with the same problem get beyond the problem at hand? So what, SO aspires to become a repository of good questions with good answer that help many people. If the task was only helping the OP, we would be a debugging / code-writing service, and most close-vote / down-vote reasons would no longer apply. Commented Aug 8, 2014 at 20:18
  • 6
    I may ask "why are you limited to X?" If the answer is "well I don't know anything else", suggesting other technologies could be useful.
    – Jongware
    Commented Aug 8, 2014 at 21:08
  • 2
    @Jongware: Please think twice before asking "why are you limited to X?". It sounds great in theory but more often than not, it's extremely irritating in practice. What ends up happening in reality is you get questions like "I'm trying to link against library X statically, how do I fix such-and-such link error?" and then people suddenly start asking "BUT WHYYYYYYY are you not linking dynamically to X!?!?!?!" and suddenly the OP has to defend his/her position, when in reality that's totally unnecessary. Just go ahead and answer the darn question assuming there is a good reason behind it.
    – user541686
    Commented Aug 9, 2014 at 6:51
  • 5
    ... and if you really think there isn't a good reason, then still answer the question assuming there is, and make a comment afterward asking the OP why this limitation was necessary, instead of withholding the information until you're convinced this is necessary. It really makes the OP's experience that much better when you answer the question and then try to suggest a better approach, instead of calling the OP's judgment into question before you've helped them in any way.
    – user541686
    Commented Aug 9, 2014 at 6:58
  • @Mehrdad: It helps not waste answerers’ time. Comparing the number of times I’ve had to answer things like “how do I use while (true) to wait for an AJAX request” when the asker just didn’t know it was possible to wait any other way and wanted to write a good question versus actually having some ridiculous constraints… it’s always better to ask for clarification. It doesn’t have to be rude or even intrusive, just offer up an alternative and confirm that the asker indeed can’t do that (or even if they think they can’t, why not).
    – Ry- Mod
    Commented Aug 11, 2014 at 3:17
  • 1
    @minitech: If it was just a matter of "clarification" or a matter of the OP being a newbie to that technology, then I'd agree with you. The problem is that it hurts those of us who really do know what we're doing and really do want an answer to the question as-is. Almost every time I have been asked "why do you want to do this?" I've found it nearly impossible to convince the asker that this is indeed what I want to do. Either they end up being stubborn and telling me to do things the "Right" way, or I have to explain something long and completely irrelevant to convince them otherwise.
    – user541686
    Commented Aug 11, 2014 at 3:58
  • @minitech: That's why I say these questions should be asked after the answer is posted, rather than before. It's just so extremely frustrating when people withhold knowledge because they feel like judges that need to be convinced whether or not you're using it properly. Often if they're not convinced, they end up downvoting the question too. I'd much rather be told the answer and judged later rather than the other way around.
    – user541686
    Commented Aug 11, 2014 at 4:01
  • 1
    @Mehrdad If you have people questioning your methods instead of giving you a direct answer, then you probably haven't communicated your true problem effectively in the first place Commented Aug 11, 2014 at 4:22
  • 1
    @SamIam: Huh? I'd argue otherwise. Just because I have to do X it doesn't mean the reason is relevant. Maybe I just want to learn how to do X. Or maybe someone else asked me and it's none of my business why they wanted to do it. Why should I have to give a convincing reason for it? Why can't people just answer the question as it was posed?
    – user541686
    Commented Aug 11, 2014 at 4:24
  • @Mehrdad They can't just answer the question for the same reason why you can't just answer debugging questions that tell you it doesn't work. Because you haven't fully told them your problem yet. Commented Aug 11, 2014 at 4:26
  • @SamIam: ...what? How would you know I haven't?! When people ask a question, they expect an answer. There doesn't have to be a larger "problem" behind it, and if there is, that problem isn't necessarily anyone's business. If I asked you "How do I solve x^2 + 2x + 1 = 0?" it is 100% irrelevant why I wanted to solve that equation. The question is complete as-is regardless of whether you feel convinced that the equation is worth solving. All you can (and should) do is to tell me to use the quadratic equation to get -1. Why would the reason behind it be any of your business? It isn't.
    – user541686
    Commented Aug 11, 2014 at 4:31
  • @Mehrdad When people are giving you invalid suggestions, it's painfully clear that your question didn't cause them to fully understand the problem. I don't get what's so hard to understand about that Commented Aug 11, 2014 at 4:36
  • @SamIam: What is painfully clear to me is that you're entirely changing the scenario we're talking about. Who said anything about people giving "invalid suggestions" in the first place? There's no "suggestion" involved in "Why are you limited to X?"; that's more like an interrogation.
    – user541686
    Commented Aug 11, 2014 at 4:40
  • @Mehrdad Oh sorry, I had assumed assumed that you were referring to invalid answers, because it seemed as though you had a problem with something. If people are posting answers that suggest that you use a different technology, and they are valid, then there isn't even a problem at all Commented Aug 11, 2014 at 14:02
10

I often see questions where the user has tagged it one way, but I think a different tool/technology could solve the problem better. In that case, I think it is fine to provide a solution that works, and leave it up to the OP and community so see if they like, or can use, the approach I am suggesting. If they can't, or it doesn't fit their environment or toolset, that's fine, so be it.

I see very little reason to downvote answers - unless they are incompetent, offensive or wrong. I prefer to just see better answers rising to the top on their merits (and upvotes) and poorer ones sinking to the bottom without needing to be shot down in flames.

Obviously, if the user says "I only have ksh and must use that", then I will respect that, but many times users just tag questions with what they think is the tool/technology they think is involved when there may be any number of other tools and technolgies that could do the job better. It is possible, and quite likely, that people who don't know enough to solve their own questions, by the same token, are unaware of techniques and tools that could help them.

My motto is to make suggestions that help or lead in a positive direction, without being unnecessarily fettered by tags (which I perceive as suggestions not constraints) and let OPs and community choose and upvote answers on their merits.

Just my 2 pence :-)

4

There are some cases where, even if the OP isn't asking about the best technology, it's clearly an appropriate enough technology, he mostly understands it but is just missing one piece, and it's pretty plausible that future searchers will have the exact same question. For example, in the Python tag, people frequently ask questions about urllib2.urlopen/urllib.request.urlopen—e.g., they've accidentally passed an already-url-encoded string in to be url-encoded, then attached it as the POST data or GET query. The obvious right answer here is to explain where they're double-encoding their data; once they understand that, they fix their code, and it works. But invariably someone will post, "Don't use urlopen, install requests and use that instead," with completely different code that works, but doesn't show the OP what he did wrong. That's not good.

On the other extreme, there are questions that are clearly instances of the XY problem. Of course many of these are just very bad questions, like "How do I use re.search without having it do all that regular expression stuff?", but even when they're not terrible questions, the answer is still going to be, "If you don't want to match regular expressions, use str.find, not re.search" (with some more explanation and an example).

But in between those two extremes, there are cases where what the OP's trying can be done, but probably shouldn't be done that way, e.g., "I want to create 200 global variables dynamically". In that case, I think the best answer is to give them both: explain how to create 200 global variables dynamically with globals(), but also explain why that's probably a bad idea, and show how to create and use a single dict with 200 keys in it instead. Sometimes that will take too much effort, or require too long of an answer. But that just means you can't always write the ideal answer, not that it wouldn't be ideal if you could.

1
  • completely different code that works, but doesn't show the OP what he did wrong +1. I don't like to see an answer with all-new code when the original code is very nearly correct.
    – Rawling
    Commented Sep 9, 2014 at 8:24
4

IMHO, there's a difference between:

"If you use jQuery, then it's really easy. Add jQuery like this, now use this one line of code."

and

"Don't use Backbone, use jQuery instead. Then you wouldn't have run into this problem."

The first is constructive, offers an easy way forward, and is genuinely a good solution to the current situation. It also probably tells the user something they didn't know - that jQuery exists.

The second is an agenda. It's not helpful, because reworking a whole web application to use one framework instead of another is a huge undertaking and probably completely unwarranted for this tiny problem. It's more an admission of ignorance by the answerer (who doesn't know how to solve problems with Backbone) than a useful next step.

[apologies if my examples are a bit nonsensical]

So the guideline: it's ok to propose alternative technologies if they are legitimate, viable next steps for this problem. Harping on alternative technologies when a clear decision has been made is not on.

2
  • Agreed. In addition, many times people ask "I want to do this without reason because: homework/to heavyweight/other" and people still answer with jQuery code. Also not constructive.
    – GolezTrol
    Commented Aug 11, 2014 at 7:49
  • This is exactly what I'm talking about, but on a repeated basis. The once-in-a-whiles of this go largely unnoticed by me. It's when I see the same user with the same comment about the same technology over and over again that seems more agenda-driven vs. being helpful.
    – splungebob
    Commented Sep 8, 2014 at 16:35
4

Sometimes they used X because didn't know how Y works (or of their existence). And it's why this site is a great place to learn new things.

Most users here are to help users to improve their skills, it makes no sense to post an answer with 500 line of code when it could be 2 lines with Y.

Maybe a section in the answer about "how it could be done in X" would make the answer more "legal" in your view point but personally who post a question here is because they need help to fix the problem in the best way possible, and I lived this fact personally with my question (AsyncTask and Queue) where I used the wrong approch and thanks to the CommonsWare answer I improved the code and my skills.

Anyway, in most cases, if you are forced to use X just put it in the question. It happen often with questions from students where they are forced to use arrays and most users comment with "why not List?".

1
  • A common example of this is Java programmers trying to use floating point for money calculations, which are almost always easier to do correctly in BigDecimal. Often I know ways the particular calculation could be done in double and get the right answer, but it would be much more complicated than using the more appropriate data type. Commented Aug 12, 2014 at 1:14
-1

If the user is in a position where he needs to achieve a task and can choose which languages / tools to use, then it may well be that Javascript is not the best languages for the situation etc.

However it may be that the user has no choice and must use Javascript or whatever technlogy and is looking for a solution in that particular language (and has probably tried something).

You could suggest something in an answer like:.. "if you're free to use jquery then you can solve this problem more easily by doing ..." whatever.

You must log in to answer this question.

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