1

Yesterday I came up with this post I answered.

I write answers made of what I considered better pratices than the OP was using because he didn't seemed really sure about it.

Basically instead accessing a .txt to populate a select dropdown I exposed that he should not use that and pointed out that there are better ways, which I introduced to him such us JSON or DB tables.

The thing is I got downvoted, the reason was I wasn't answering what the question was about.

I asnwered that way because is what I would like to get if I ask something with wrong bases, but is it ok? What is better, to teach the OP or give him a copy-paste code and go for the next one?

7
  • 2
    Well, people who want you to spoon-fed them the answer are rarely going to be happy with an answer that makes them think and do work for themselves. Some downvotes are inevitable. Strive to provide the best, most useful answer to a question, not copy-paste-ready code. Mar 9, 2016 at 8:29
  • I consider giving alternatives as good bonus to the answer itself. Maybe OP has no choice using this txt file which will be generated by another process he has no control over, etc. So When answering a Q, try to answer it when possible, and if there's better alternatives say a word about them. (Or at least ask in comment if alternatives are possible if OP didn't state it clearly)
    – Tensibai
    Mar 9, 2016 at 8:31
  • @Tensibai The thing is that in this particular case, the OP didn't seam sure at all about using the .txt , he said that he didn't know if it was even possible so I considered to guide him to a better solution...
    – Asur
    Mar 9, 2016 at 8:33
  • 1
    Well reading the comments under your answer, it's quite clear why it gets downvoted, not the same language and not answering at all the original Q. And I would disagree doing client side generation is a good practice toward server side generation :)
    – Tensibai
    Mar 9, 2016 at 8:35
  • I see you updated (looking at history, but sadly some never get back to review their downvotes, it happens :p)
    – Tensibai
    Mar 9, 2016 at 8:36
  • @Tensibai Yes I updated it because I got a comment which had a point, first of all I only had JQuery answer, so I added a PHP part, he had time to review it because he just answered right after me. But I don't really care about downvotes them selves but their meaning... ( They prefer to get a copy-paste fragment than a instructive answer)
    – Asur
    Mar 9, 2016 at 8:40
  • I think it has more to do with your opinion, what your consider better practice is not agreed by everyone. My 2 cts, I would better base myself on a request to iso.org/obp/ui/#search to get the actual updated list, or search for any other way to get the list up-to-date without worrying about it. It's an opiniated advice, not really an answer :)
    – Tensibai
    Mar 9, 2016 at 8:49

1 Answer 1

5

Like many things, "best practices"-answers have their place and time. I feel that this is the wrong place for a "best practice" answer.

There is nothing wrong with keeping a list of countries in a plain text file depending on the circumstances. In this question, there is little context, and no reason to assume that keeping said list in a plain text file is "wrong". In fact, I personally see little advantage over JSON or XML here. And using a database table might be okay if you're already using a database, and even then it's not strictly "required".

Furthermore, you initially posted JavaScript-only answer on a PHP question. You may feel that doing it this with jQuery and AJAX is better, but that's obviously not what's asked here, and rendering this server-side is fine (in fact better I would say).

Imagine if everyone would do this:

  • All JSON question would get a "No use XML"-answer.
  • All XML question would get a "No use JSON "-answer.
  • All Python questions would get a "No use Ruby"-anser.
  • All Ruby questions would get a "No use Python "-anser.
  • ...etc...

I'm not downvoting this as it already has two downvotes and because posts on meta tend to attract attention and excessive downvotes (the so-called meta effect), but if I had encountered it in the wild, I would have downvoted it as it doesn't really answer the asked question.

The best thing to do is usually:

  • First answer the actual asked question.
  • Then expand why you feel this is a bad idea, and offer a better solution.

For example a few days ago I posted an answer here which detailed why I felt that the asker was making a mistake in asking for this. But I also offered a possible solution which directly answered the question in case she disagrees and really wants to do this.

0

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