Article 66TR5 CodeSOD: Holiday Sample Pack

CodeSOD: Holiday Sample Pack

by
Remy Porter
from The Daily WTF on (#66TR5)

Today, let's whip up a holiday sampler of some short snippets. We start with this anonymously supplied ternary from a C program, which certainly terned my head:

return (accounts == 1 ? 1 : accounts)

If accounts equals 1, return 1, otherwise return accounts. Perfect.

On the other hand, submitter Born 2 Ruby, Forced 2 PHP was hired to work on a Ruby on Rails application, but after starting, discovered that the RoR app was an aspiration and the day to day work was to keep the legacy PHP application from falling over in production. So as it turns out, this submitter should have said "no", when they said "yes", much like this code:

function yesorno($in) { if($in == 'YES') return 'YES'; else return 'NO';}

And finally, another anonymous submitter sent us this comment they wrote in their code, which I think speaks both for themselves and for anyone who even inherits that code.

// i should have commented this stupid code
proget-icon.png [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments