Shit programmers write
11–20 of 82 posts
Re: Shit programmers write
#12Re: Shit programmers write
#13Love this one: return foo == null ? null : foo;
This reminds me of this one, which is quite common: return foo == null ? true : false;
Re: Shit programmers write
#14> if (Session["startDate"] + "" == "") This feels horribly familiar. I'm not sure to recognize the specific language used, but there must be cases where one would like to target empty of filled with non processable characters strings only, and let null and falsy values pass through. This kind of use would typically need a line of comment, but hey...
I'm guessing you don't realize that the plus operator has less precedence than the == operator. That if is equivalent to if (startDate + true) EDIT: I was wrong. I haven't slept.
Re: Shit programmers write
#15More frequently updated: http://thedailywtf.com/
Re: Shit programmers write
#16Maybe we should reevaluate some best practices. I have debated before on here that many unit tests seem useless as the units are too small, and you essentially end up testing your language or framework which you already know works. Integration testing on the other hand makes a lot more sens.
When I started with Java, it seemed appropriate to put hundreds of getter / setter methods. Is there much advantage to that over allowing the variable to be accessed directly? (Perl felt very strange at first having getter and setter methods combined as one method).
As I get more experienced as a developer, my skill set has grown but my coding becomes simpler. Don't use every language feature to show how knowledgeable you are. Use it when appropriate, and when it makes the code more readable / reusable / simpler. Sometimes a higher level abstraction is more difficult to understand , but is overall better choice. An example would be a map as opposed to a for loop. Less chance of side effects in a map, as we don't have to track the iterator variable, but a map is not as intuitive for less experienced coders.
Re: Shit programmers write
#17Re: Shit programmers write
#18Earlier quoted context omitted.
This reminds me of this one, which is quite common: return foo == null ? true : false;
I sometimes do that in PHP because I hate the equivalence between "", false, null, '0' and 0. Seeing true and false written out makes it more readable.
Re: Shit programmers write
#19Love this one: return foo == null ? null : foo;
Rather, it "evolves".
It starts as:
return foo == null ? error_handler(bar) : foo;
And someone realizes error_handler actually does nothing, so replaces all calls with null, mechanically.Re: Shit programmers write
#20Earlier quoted context omitted.
I'm guessing you don't realize that the plus operator has less precedence than the == operator. That if is equivalent to if (startDate + true) EDIT: I was wrong. I haven't slept.
Does it mean if(1 + 1 == 2) is equivalent to if(1 + true)?
2) even if == had a higher precedence, then 1 == 2 would still be false :D