- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
if($showType == 'frist' || $showType == 'frist') { // debug('frist'); }
Admin
"if($showType == 'unassigned' || $showType == 'unassigned' " My guess is that there once was a third possible value, that later became incorporated in "unassigned". So someone used "find and replace in files" to replace the obsolete state into "unassigned. My 5 cents...
Admin
Not too much of a wtf, just sloppily written code. Come on, you can do better..
Admin
I think that once upon a time, there was a problem with ticket 400220 and that code was added to debug it. When the debugging was done, only the debug output was commented out, rather than removing the whole loop.
It's like this code was maintained by middle-schoolers with ADD.
Admin
INB4 "PHP is TRWTF"
Admin
In defence of the special UUID - well, if the requirement occurs three times more, THAT is the time to start thinking about a database flag. No point in altering the poor bloody database for all time, with extra logic drag forever, if this feature is only asked for once and turns out not to be a good idea.
Admin
The zen of YAGNI is that you assume you're not going to need it, but you're happy to change your mind when actual experience says otherwise. And you'll usually be right, and virtually never regret not having wrote it in the first place.
So you don't write the UI, a complex thing you'll have to maintain and which is a security risk, until updating it manually becomes enough of a PITA to justify it.
Admin
I've been guilty of writing code that looks an awful lot like that last snippet, though this was in the context of refactoring existing legacy code that already had if statements that ended up looking like if(a == "a" || a == "b" || a == "c" || ...) It sometimes worth looking at the context around when the WTF was originally added in and what the code looked like previously. In the case of this story, however, it's really difficult to defend (checking against specific UUIDS??). At least the variable name clearly notes that it's a hack.
Admin
This is such an exception, all other PHP code in the world is usually written perfectly!!!
Admin
Sloppy, but not particularly WTF.
Admin
We've got plenty of instances of code like this where it's specific records with specific conditions worth tracking.
Admin
Where's the WTF?
Admin
First "issue": probably a global search and replace, maybe from the command line. Imagine three states, say "new," "unassigned," and "free." The penny drops and you realise that "free" and "unassigned" are, in all cases, the same thing. Now, I could moan about string-worship and lack of encapsulated behavior in the type system, but hey, PHP. It's what you do, man. It is not a WTF.
Second "issue": Sales guy comes in and tells you that you need to implement a debug workaround for "My Big Customer, just this once, ticket 400220," this is what you do. Setting some stupid global constant to 400220 won't make any real difference. There's a minor WTF in that it applies to all "Host Organisations," but, you know, worse things happen at sea.
Third "issue": Just chuck an extra column in the database schema? Why? This appears, from the comments, to be another one-off and temporary request. I think I'd rather see a single line code implementation than a pointlessly bloated schema. Granted, it's a GUID, and I hate bloody GUIDs and I have spent three whole years tracking down bloody stupid GUID cross-references in different XML files, just because the maniacs in charge didn't want a database, but even I don't really care that much.
Seriously. None of this would make me think "WTF." Unless I was your correspondent's manager, in which case I would take them aside, buy them a nice meal, and explain how the real world works.
Admin
My professor told stories of trying to run programs on a CDC 1604, circa, 1962. The 1604 was made up mostly of transistors that were floor-sweepings, rejected and never marked with a part number, but very cheap. Seymour Cray managed to design logic gates that often worked. But the computer still was so unreliable you often DID run checks twice, just to be sure the hardware did them right. They really should have used majority-voting with an odd number of tries.
But that was way back. My guess is his ^V key stuttered or they intentionally left in an extra test for future expansion of the kludges. Even kludges should have Best Practices in mind.
Admin
Not actually related to this story, more to this website.
Recently the rendering of the page takes ages. For example, on this page it immediately printed everything up to "if the debug statement isn't commented" and then it took about half a minute to render the 'out' and the rest of the page.
Looking at the code, it seems as if it has something to do with the cornify script, whatever that is for. But apparently it's waiting to time out.
Btw: I'm using Chromium-browser on Linux Mint.
Does anyone else have this issue?
Admin
"I'll only need this once" is the biggest lie users tell. Right after "I didn't change anything". And "I have task X all the time, I need an interface for it". Go on, deliver a broken interface, see if they ever notice.
Admin
Quite. The biggest WTF is anyone sentient being unable to imagine a dozen ways the first one could have happened. Sure, it's not great, but it's perfectly understandable that it might have been created for a not very good reason.
Admin
I agree, except with the GUID part. They are entirely unrelated to whether or not you have a database, and depending on the context may be the most sensible solution as identifiers.