Shit programmers write
31–40 of 82 posts
Re: Shit programmers write
#32Earlier quoted context omitted.
The result of "foo == null" (or better "foo === null") is boolean, I don't know what is the "equivalence" problem here.
Maybe this is a programmer who likes to spell things out for future readers. It's easier to convey meaning with return foo == null ? true : false;
"Hmmm, if 'foo == null' is true, than it's true... I see..."
Seriously..
Re: Shit programmers write
#33More frequently updated: http://thedailywtf.com/
Re: Shit programmers write
#34Earlier quoted context omitted.
I shell languages I do this a lot. if "x$VARIABLE" == "x" because it handles the cases where $VARIABLE is undefined or multiple words without vomiting all over the place.
I hate when people do that because it's not needed at all. The quoting already fixes everything. if [[ "$VARIABLE" == "" ]] or even better if [ -z "$VARIABLE" ] will handle undefined, empty and multiple words just fine.
if [[ -z "${VARIABLE:-}" ]]Re: Shit programmers write
#35A lot of these seem to be Microsoft technologies like C# or SQL server. Is that because the owner is more familiar with the MS stack? Or do MS devs have more to complain about?
I once had to print a method that took 50 pages of paper, so I could understand what it does, and after 15 minutes I realized it's the same 60 lines repeated over and over with different conditions. The guy who wrote it had no idea he could have extracted a method.
Re: Shit programmers write
#36A lot of these seem to be Microsoft technologies like C# or SQL server. Is that because the owner is more familiar with the MS stack? Or do MS devs have more to complain about?
It's not meant to be specific to any language. It's just funny shit people have written.
I submitted a few from old code I wrote like 5 years ago. Its all good fun :)
Re: Shit programmers write
#37A lot of these seem to be attempts to fit into existing "best practices". Unit tests that prove nothing. Boilerplate Java code that does nothing. Maybe 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 make…
Re: Shit programmers write
#38 function nop()
{
if (Math.random() == 0.1234567890)
{
for (var i = 0; i
wouldn't have been written in JavaScript, my guess would be that this is an attempt to create an empty function (no-op) and prevent it from being optimized away by the compiler. Still unclear who may need to call it.Re: Shit programmers write
#39> 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...
Though not sure why it was required for this particular comparison.
Re: Shit programmers write
#40A lot of these seem to be Microsoft technologies like C# or SQL server. Is that because the owner is more familiar with the MS stack? Or do MS devs have more to complain about?
From my experience, such code is not specific to MS technologies, but is indeed often found in “enterprisey” code, a lot of which just happens to be in Java and C#. And enterprisey code is like that because it's often outsourced to the lowest bidder. I once had to print a method that took 50 pages of paper, so I could understand what it does, and after 15 minutes I realized it's the same 60 lines repeated over and ov…