Is it on-topic to ask a question with two more or less equivalent snippets, and ask which of the two snippets is considered the most clean?
The way I see it, there are four possible answers here:
- Snippet #1, because [reason].
- Snippet #2, because [reason].
- It's a matter of taste (because [reason]).
- You should write it like this [demonstration] because [reason].
The obvious concern here is questions that are likely to cause debate. Would the potential-debate-factor be limited by the limited set of answers? Are such questions more prone to debate than regular code review answers?
Example
switch (score)
{
case 0: return "Love-All";
case 1: return "Fifteen-All";
case 2: return "Thirty-All";
case 3: return "Forty-All";
default: return "Deuce";
}
vs.
if (score > 3) return "Deuce";
string[] scoreNames = { "Love-All", "Fifteen-All", "Thirty-All", "Forty-All" };
return scoreNames[score];