What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

Question

If someone decides to post non-scalable code that does answer the OP's question (and isn't dangerous code, IE mysql_* in PHP), should they be downvoted? Why or Why Not?

My 2 Cents

The down and upvote buttons say to down or upvote if useful, I would assume though being non-scalable, any answer that answers the OP and is not dangerous would be considered useful. At the very least I would assume non-scalable answers should be at 0 votes. What do you think?

My point is summarized better by casperOne:

You can downvote the answers if you want, but to put a meta answer out there that says "oh, if the code written for the answer, regardless of the fact that it correctly answers the question doesn't scale, you should downvote it" is very, very bad as we're now enforcing a higher standard which wasn't there to begin with.

Example

switch vs associative array iteration

share|improve this question
5  
What is "non-scalable" code? Are you referring to a specific answer? How about providing a link to it? –  Robert Harvey Aug 2 '12 at 15:23
9  
If you feel the answer is not useful, down vote it, simple as that. However recognizing the code as "non-scalable" probably means that you have a scalable solution to the question, in which case the best course of action would be to post an answer. –  Yannis Aug 2 '12 at 15:27
1  
I believe this answer is the one in question. –  nickb Aug 2 '12 at 15:28
    
@nickb I specifically didn't add that because I'm not looking for pity or sympathy upvotes. I'm looking for intelligent discourse on the subject. –  Event_Horizon Aug 2 '12 at 15:30
3  
@Event_Horizon: downvotes cast in good faith† are always valid. († those found not to be serial in nature or part of a concerted voting fraud effort) –  user7116 Aug 2 '12 at 15:39
1  
To expand on Yannis's and sixlettervariables', you aren't going to get the team to reverse votes cast in good faith and you aren't going to get a ruling that says "You shouldn't downvote answer unless there a really really wrong". These things just aren't going to happen. The votes represent how the crowd feels about the utility of the answer. –  dmckee Aug 2 '12 at 16:19
    
@dmckee I never said I wanted the votes reversed, and I never said I wanted a ruling on how to downvote. I posted this for discussion on downvoting non-scalable code, and DIDN'T include the post that gave me the discussion idea because I wasn't looking for sympathy or anything other than discussion. –  Event_Horizon Aug 2 '12 at 16:22
4  
@Event_Horizon Discussions on meta exist to work towards a consensus on how things should be. That's what meta is for. So, in effect, you asked for a ruling on how people vote on code that scales poorly. I know it feels like you're being picked on, but long time programmers develop strong feeling about coding practice because they've been bitten on the ass over and over again. It makes them seem harshly judgmental, but they are in fact being eminently reasonable. The associative array solution is much better. –  dmckee Aug 2 '12 at 16:28
    
@dmckee Your not listening to what I'm saying, I don't care about being picked on or whatever, which is why I never posted my answer to begin with. I was only asking for discourse on non-scalable downvoting. Yes the associative array solution IS better, thats why I would upvote it, but I personally wouldn't downvote code unless its doing something dangerous or it doesn't work. I completely understand having strong feelings about coding practices, but its not bad coding practice in a 3 case scenario. –  Event_Horizon Aug 2 '12 at 16:33
    
-1 disagree, see my answer –  Lee Louviere Aug 2 '12 at 20:32
add comment

4 Answers

up vote 8 down vote accepted

There's no mandate to downvote answers which do not conform to some gold standard for code "whatever." If that were true, few answers on Stack Overflow would muster any upvotes, since the TDD crowd would insist on seeing your unit tests.

Consider this question: How to add 'ff ff ff ff' (HEX) before the data of an byte[] array?

The answer I provided is probably not ideal from a performance standpoint. However, the answer I gave was tailored to the OP's specific level of expertise (he is a neophyte), and the link below the answer points to a number of optimizations, if the OP is so inclined to explore those.

Should my answer be downvoted, because it is not optimal? I'm not so sure about that.

In the post referred to here, I would note that the OP never asked for a "scalable" solution. In fact, the OP specifically stated that he's only interested in his three cases, and that's all.

Sometimes good enough is good enough.

share|improve this answer
1  
It's that PHP global variables answer all over again. –  Kev Aug 2 '12 at 16:49
    
@Kev On that note, is the Global keyword depreciated yet? –  Event_Horizon Aug 2 '12 at 16:49
    
@Kev: PHP is a particularly contentious tag; it seems to attract many marginal answers. I don't necessarily blame people for downvoting answers in that tag that are less than ideal. –  Robert Harvey Aug 2 '12 at 16:51
add comment

If you are referring to this answer, yes, I think downvoting is justified.

It may fulfill the OP's exact requirement, but let's face it, it's not code you want to have in a production environment because it's just not a nice solution to the problem.

That said, your answer isn't the only terrible one in there. Off to do some voting...

To elaborate on the "why": SO is striving to be an archive of canonical questions and answers rather than a help forum. Therefore, answers should try to be useful for the general public.

Your answer is not good programming practice beyond that very specific use case; we don't want to teach people bad programming practice. Hence, a downvote is fair game.

(That would be my rationale for downvoting in any case - I'm not actually going to vote there to avoid distortion because of the additional attention it gets on Meta now.)

share|improve this answer
    
How so, the OP specifically asks about 3 descriptions. For that use case that answer is perfectly fine. –  Event_Horizon Aug 2 '12 at 15:33
2  
@Event SO is striving to be an archive of canonical questions and answers rather than a help forum. Therefore, answers should try to be useful for the general public. Your answer is not good programming practice beyond that very specific use case, and we don't want to teach people bad programming practice. That would be my rationale for downvoting in any case - I'm not actually going to vote there to avoid distortion because of the attention got on Meta. –  Pëkka Aug 2 '12 at 15:36
    
How is it bad programming practice to use a switch statement when you only have 3 cases? –  Event_Horizon Aug 2 '12 at 15:37
    
@Event simple: it may not stay at 3 cases. –  Pëkka Aug 2 '12 at 15:41
    
So? That's the OP's decision to make later, his question is about 3 cases, and the answer fits it fine and isn't bad practice for the question when it refers to a 3 case situation. If he hadn't said he only had 3 cases I might agree with you. –  Event_Horizon Aug 2 '12 at 15:42
    
@Event yeah, true; and it's every user's decision how they use their vote. As said, SO is about answers that are valuable to a larger audience than just the OP. –  Pëkka Aug 2 '12 at 15:45
    
I just find it daft to downvote an answer for being non-scalable. Especially if OP asked for something non-scalable. And that's the only reason for the downvotes from what I can tell. –  Event_Horizon Aug 2 '12 at 15:46
1  
@Event_Horizon -- go back and read the question; it is not about three cases. He says: "I have a series of if statements in PHP. To simplify..." and then shows an example. He might already have 20 or 200 cases! –  Ernest Friedman-Hill Aug 2 '12 at 15:48
    
@ErnestFriedman-Hill Directly from the question QUESTION:What code would I need to edit/add so that the final else statement picks one of the 3 description variables so that I can then echo it on the page? that says to me there are only 3 cases. –  Event_Horizon Aug 2 '12 at 15:49
    
@Event there's no point in discussing this with us. We didn't cast the downvotes; I tried to explain what motives and philophies probably caused them. You can accept those motives or reject them, it's up to you –  Pëkka Aug 2 '12 at 15:50
1  
@Pekka if theres no point then why did you bring up the post, there was no good reason to include it when the question ISN'T about that post, its about whether people should downvote non-scalable code. –  Event_Horizon Aug 2 '12 at 15:51
4  
@Event yes, people should downvote non-scalable code such as that in your answer. IMO. For the reason stated three times now: answers aren't for the OP only, they are for future generations as well. –  Pëkka Aug 2 '12 at 15:53
1  
I disagree; it's one thing to not encourage bad programming practice, but despite the desire to become the canonical resource, scalability can be tied to the specific implementation you're working on. That said, anything on the internet is caveat emptor, SO included. You can downvote the answers if you want, but to put a meta answer out there that says "oh, if the code written for the answer, regardless of the fact that it correctly answers the question doesn't scale, you should downvote it" is very, very bad as we're now enforcing a higher standard which wasn't there to begin with. –  casperOne Aug 2 '12 at 16:23
    
I'd still like to know what "non-scalable code" means. Am I the only one here who doesn't understand this term? Scalable to me means it can gracefully handle an increasing number of users or workload, but that's not how the term seems to be used here. Did you guys just make it up for this question? –  Robert Harvey Aug 2 '12 at 16:33
    
@RobertHarvey Scalable Code means it can handle more than a specific number of cases without adding code. Switch statements can't because you have to add code the more cases you have. With an associative array you can auto fill them with whatever and iterate through them without building more code than the general iterator usually. It also refers to being able to handle more users (by being dynamic). –  Event_Horizon Aug 2 '12 at 16:35
show 4 more comments

Downvoting is the right of every Stack Overflow user of 125 rep or more. You are allowed to downvote a question/answer for any reason whatsoever, or even none at all.

If someone doesn't like the fact that your answer uses Hungarian notation for variable names, you may get a downvote. If someone doesn't like the fact that your answer uses JQuery, you may get a downvote. If you're knowledgeable about a subject that has very little expertise, and your answer flies in the face of conventional wisdom, you may get a downvote. I've even gotten a downvote because my answer actually answered the question that was asked (about what the language says about something), rather than what the downvoter wanted the question to say (about what compilers do when compiling it).

You will be downvoted for reasons you don't agree with. You will be downvoted for dubious reasons.

Deal with it.

That's not to say that this is a good thing, mind you. But we aren't going to police random downvotes. Democracy means that everyone gets a vote. It also means that people can vote badly and/or in ignorance.

share|improve this answer
2  
I would only add that the answer being debated has multiple downvotes, so there seems to be some community consensus about the answer's veracity. –  Robert Harvey Aug 2 '12 at 17:15
1  
@RobertHarvey Well, some of them may have happened because this thread drew attention to the matter. That answer isn't horrible, just sub optimal in a language that makes a better way easy. Building the associate solution in plain old c would require considerable code and using the quick -n-dirty solution would be defensible in more cases. –  dmckee Aug 3 '12 at 13:33
add comment

Please don't. Simply post a competing answer and alert some high rep people to endorse if they agree. But comment why you think your scaling answer is best ("Scales Better" is good enough).

The last thing I want is to turn this site into code-nazis who go around blasting people's legitimate answers because they don't meet a requirement the OP may legitimately not care about.

There are legitimate cases where the OP doesn't want the answer to scale, or can't afford the memory to have it scale, where hard-coding is best (small embedded devices with low memory / processing power).

share|improve this answer
    
ok, fair enough, but then you have to upvote the OP (as he is the author of a non-scaling answer that got downvoted) –  Pëkka Aug 2 '12 at 20:33
    
@Pekka I've been the target of this before, and now I just avoid the tag. True, I learned that my solution wasn't a good one, and the tag regulars were on a campaign against the common bad answer. But they should have posted the right answer and upvoted it instead. I feel downvotes should be reserved for incorrect answers. –  Lee Louviere Aug 2 '12 at 20:38
    
no, I mean downvoting the OP of this question (as you indicated in the comment above) does not make sense if this is your opinion. Because the OP actually agrees with you –  Pëkka Aug 2 '12 at 20:40
add comment

You must log in to answer this question.

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