5

Imagine a question:

I have to do <some task>. I am trying to do this task in <some situation>. I can think of two technically valid ways to do this task. Here they are:

Way 1:

 //snip

Way 2:

 //snip

Does there exist a clear cut advantage to Way 1 over Way 2 (or vice versa), or is the choice here just a matter of opinion? Am I just bike-shedding?

Would a question of this sort be ? The issue itself very easily could be, and, in fact, the question-asker is clearly not certain. But could there perhaps be an objective, on-topic question asking whether it is or not?

Meta-thought: Is this question opinion based? ;)

  • 4
    I think you have a valid question, but I was obligated to vote-to-close as "primarily opinion based." – GlenH7 Mar 19 '14 at 19:10
  • with sufficient research effort invested, this can probably make a reasonable design review question – gnat Mar 19 '14 at 20:18
3

Sure!

Suppose there are actual differences between Way #1 and Way #2. These would be good answers:

  • "Way #1 exposes you to a race condition where...but the X in Way #2 avoids this problem."
  • "Way #1 has better worst-case performance, even though Way #2 is, on average, faster"

Alternately, if there's no difference:

  • "No. Way #1 actually just calls something that wraps the method called in Way #2 [link to docs]"

would be a great answer too, particularly if it's not something super obvious.

On the other hand, asking people to choose which of the following is better:

if(quantity==1)
   printf("1 item received.\n");
else
   printf("%d items received.\n", quantity);

or

printf('%d %s received\n.", quantity, quantity==1 ? "item" : "items");

is indeed boring, but that's what downvotes are for. If you're feeling more generous, it's potentially a duplicate of a question about the ternary operator too.

  • Personally I think both example questions you have posted here are valid questions for the site. The key point to make in your 2nd example question is code readability and maintenance vs minimum lines of code. That said, you are also correct that the 2nd example question should probably be closed as a duplicate :) – Rachel Mar 20 '14 at 15:08

You must log in to answer this question.

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