- 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
IMHO the biggest WTF is replacing invalid user input with some default value. I just hate it. Typos are a lot easier to fix when you don't have retype everything.
Admin
Of course it is, it's contraction of "pay would" as in What do you expect from this job? Well, pay'd be nice.
Admin
I've seen a project with some similarly horrible date wrangling code in PHP. To generate a drop down list of twelve months we have this abomination
for($tempMonth = 1; $tempMonth <= 12; $tempMonth++) { $tempMonthText = date('F', ($tempMonth - 1)60602431); $template->set_var(array( 'vMonth' => $tempMonth, 'vMonthText' => $tempMonthText, )); $template->parse('bMonth_Block', 'bMonth', true); }
Unsurprisingly when testing it on a particular day in August the whole month of February just "disappeared" from the drop down list !
It got rewritten using an array listing the 12 month names...
Admin
Admin
For random, far-distant dates this is true. For "later this month" dates (like online bill pay) this is false. I'd much rather click the date in a mini-calendar than get out my own calendar and decide which date to type in.
I don't really have a problem with these if they are implemented correctly. By which I mean that the option values begin with the state name or abbreviation (no prefixed "-" or " " etc.). Any reasonable browser will allow you to click on the field and type the first few letters of the state you're looking for. This works less-well when random garbage is inserted by the designer because it "looks better".
Admin
Admin
Nerds are bad at handling dates, isn't it clear :-)
"The rest of us" really wonders why validating a date with any sort of hammer wouldn't be a federal crime
Thanks, I'll be here all night!
Admin
Admin
If I had goggles for my brain and I tried to understand why, they'd still do nothing.
Admin
At least 70, inluding..
Decimal Octal Hex Binary Value
057 071 039 00111001 9 058 072 03A 00111010 : 059 073 03B 00111011 ; 060 074 03C 00111100 < 061 075 03D 00111101 = 062 076 03E 00111110 > 063 077 03F 00111111 ? 064 100 040 01000000 @ 065 101 041 01000001 A 066 102 042 01000010 B 067 103 043 01000011 C ... 122 172 07A 01111010 z 123 173 07B 01111011 { 124 174 07C 01111100 | 125 175 07D 01111101 } 126 176 07E 01111110 ~ 127 177 07F 01111111 DEL
Admin
[quote user="hims"][quote user="CodeRage"] I've seen bank logon pages which force you to enter passwords by selecting from a different dropdown each number or letter, and request forms which force you to enter 12 digit codes by choosing 1-9 from 12 different dropdown menus.
If I had goggles for my brain and I tried to understand why, they'd still do nothing.[/quote]
You don't need goggles to understand the logic....
One word: Keyloggers
Now, is a drop down menu the best solution? Of course not. If fact, it's one of the worst. I've seen banks create an on-screen keyboard, and that was a pretty smart solution to a real security problem. But a drop down...well, that's not really solving much of any problem since people like me tab through fields and use the keyboard to select items in a drop down.
Admin
Go french!
http://en.wikipedia.org/wiki/Decimal_time#France
They actually proposed having decimal time way back then in 1793. Days would have had 10 'hours', of 100 'minutes' each, of 100 'seconds each'.
Working upwards, they also proposed the
http://en.wikipedia.org/wiki/French_Republican_Calendar
where years had 12 months of 30 days each, with 3 10-day weeks per month, and the 5 or 6 extra days clumped together at the end of the year.
Of course, it failed miserably.
Admin
There's nothing stopping you. In fact it's used all the time for measuring time intervals. It's referred to as metric time. But since it doesn't correspond to any natural periods, it'd be inconvenient for clocks, for example.
Decimal time, on the other hand, is based on division of the day by powers of 10 and would be just as viable as the current system, but, as in the past, its adoption would be unlikely.
See also decimal calendar.
Admin
JavaScript converts strings into numbers when they are used with any operator other than concatenation/addition.
http://www.jibbering.com/faq/faq_notes/type_convert.html#tcNumber
Admin
Well, yours certainly doesn't.
Admin
Admin
Admin
Given that Americans still don't use metric, updating our time system will never occur.
I mean, really, how difficult is it to use metric? I hate having to handle both imperial and metric.
Admin
I've also previously maintained a program that was originally written by someone who left a similar marking at the top of the file, called Tony B. It was aparently Tony B's first Visual Basic program. If it's the same person, he's gone neither forwards nor backwards.
Admin
Even better is that the line actually does what it advertises if you put it in the context it's in:
if (posit0 < "0" || posit0 > "3") { alert("date contains invalid DAY default value set") ...
It does make sure it's less than 4 (and greater or equal to 0) -- only it's in negative logic and if the condition is not met, it enters the body -- which then alerts the user and dies.
Admin
Admin
That's why I only use Unix timestamps for date/time entry fields. Pfft... noobs.
Admin
Useful? Sure! And I agree, it is annoying to have to manually check back with the server, as opposed to some AJAXy method.
But mandatory? Consider:
If there is no client-side validation, some of your customers get pissed.
If there is no server-side validation, you've got a GIGANTIC FUCKING GAPING SECURITY HOLE.
One will annoy some users, and maybe waste a little bandwidth. The other will compromise your system, and very possibly expose your users to risk.
Since they're not mutually-exclusive, you do want both. But I would say the security is mandatory, and the convenience is just convenient.
Admin
Who says comments are to help the author understand his or her own code? I lace my stuff with comments simply to avoid being calling in on my vacation.
Admin
Admin
But why is it then, that daynumbers and yearnumbers are 1-based?
Admin
Admin
The Metric system is an invention of the french with the adoption thereof enforcable by death. So it caught on fast...in france. Realizing it would go about nowhere without international support they made a deal with England for the Prime Meriden. The original metric prime meridian would have run through paris. The English would have none of that poppycock, there maps weren't drawn that way and "Britannia rules the seas" you know. Somehow the french compromised our meter for your meridian.
The metric system has made strides in education because the lazy students frustrate the lazy teachers into giving up on them. Not because the bright scientific students can't +-*/ by 12! Therefore I have no sympathy for "computer guys" who can't add, subtract, multiply or divide by 12 and especially 16! Are you that F@#$%^& Lazy? Are you an art major?
Don't get me started, wait..., starting now... on how it is all based on the imperial system to begin with! If it wasn't the meter would be 1,000,000 wavelengths of some thing not some seemingly pseudo-random 1,650,763.73 wavelengths of orange-red light <snip> just so the conversion would still line up. Why not 1E6 or 2E6 wavelengths? This was a stopgap to have a more "scientific" definition of the crap. Garbage in, garbage out. The original definition was based on time so we see the whole system was dependant on the "English second."
The conversion was clever actually. 2.54 cm/ inch and 39.37 in/m both being exact is cool. Except anyone who can multiply and divide and know that there are 100 cm/m will see that these two EXACT conversions don't line up. Exact as defined by everyone to the point it is common knowledge. <insert conspiricacy theory here>
Measurement is arbitrary. Light-years are pretty good. At least they didn't base it on the distance from one corner of the earth to another. (The falling water would have eroded the edge over time of course. ;-)
In the end meter or E-meter, whatever, it's a crock of contrivance.
On another note:
I'd love to code ASM all day. I endorse meaningful comments. Coders should be more professional about their work, quit your whining, get to work. Would you rather be unemployed right now?
captcha="quibus" doesn't that have something to do with a quibble or fight? :-)
Admin
This was also the first thing that came to my mind. If there is a server side validation, then it is OK, though redundant. Some devs tend to forget that there are people who are not so into the Web 2.0 thingy / besides the security implications. But doing stuff twice seems to be a good occupation for bored developers, especially the maintenance of this stuff.
Admin
So... when encountering some piss-poor javascript, programmer replaces is with something inaccessible?
Please tell me that this new "read only" field is set to "read only" only AFTER it's clear that the javascript date picker is going to work...
followed by server-side validation...
Admin
So the metric/english argument went stale what one or two hundred years ago?
But lazy people do irk me. Heaven forbid you look up a funcion in the standard library of anything. unless you're paid by the line.
Admin
You're being very very clever and demonstrating an amazing mastery of the fine art of sarcasm, but if these "genius UI people" actually are as awful as you think they are, then what on earth makes you think they'll be any better at handling dates typed in by a user?
Yes, you're right, a badly designed calendar control isn't better than a badly designed text validator. So? One would assume, if one was smart, that a well designed control would be used.
Of course, "well designed" and "web 2.0" seem to go together like bicycles and refrigerators, so maybe the real WTF is expecting high quality in the first place.
(Also, this "30-50 times" nonsense, is, well, a slight exaggeration. Maybe once to say you want to enter a date, a couple of times to pick a year, once for a month, and once for a day. That's 5 clicks. As compared to a mimimum of 6 - 8 keypresses (4 for year, 1 or 2 for month, and 1 or 2 for day) for typing the date in, plus you have to remember what format the website expects, or have some magic code that can tell if 01/02/03 is january the second 2008, or february the third, 2001 by reading the user's mind.
Because we all know that the real WTF is a website that doesn't demand the user use the exact same date format as god in heaven and the website's designer have agreed on.
Admin
thanks for the moral support guys
Admin
Because "The 11 Days of Christmas" sounds weird.
Admin
Self explanatory code is nice and all, but there are a lot of times when something [ican[/i] be done in multiple ways. In that case, unless it truly doesn't matter which way it's done in a given program, comments are a godsend so I can see why you did it the way you did it, and sometimes more specifically why you didn't do it a different way (e.g., a non-obvious idiosyncracy that popped up that would be nice to know about as I do further work on the program).
Something like "x = 5; // set x to 5" is useless but "comments" and "useless comments" aren't the same thing. Comments---documentation in the source files---are definitely a good thing.
This would not be fixed if the coder wrote his tests first. Leap years aren't handled because he never even thought of them. What magic is going to make him think of leap years when writing the test if he didn't think of them when writing the code? Ok, you specified the lack of "comprehensive" tests as the problem, but what makes you think the guy who couldn't write comprehensive code would write comprehensive tests?
Admin
LOL. I can't understand why a "computer guy" would be saying crap like this.
Sure, I can keep track of my 1/8, 3/8, 5/16, 5/32, etc, drill bits and wrenches, but I don't want to. Doing so doesn't help the job get done any better or any faster. I'd much rather be using my metric wrenches where you go 4mm, 5mm, 6mm, and so on instead of dealing with a bunch of fractions with inconsistent denominators (which is probably the real WTF when it comes to wrenches. Just doing everything with regard to 64ths seems like it would be much nicer.)
Sorta like how I could write everything in assembly, but it would just be a bunch of wasted effort not helping get the job done any better. Though even this is more sensible than our measurement system, since going that low-level might result in a program that runs significantly faster, while I don't see any such benefit to having to deal with feet, inches, and weird-ass fractions when working with my tools.
Yes, I'm that lazy. But you say that like it's a bad thing. Why not use the tools that let the job be done the quickest, with the least complexity? These days, laziness is the mother of invention.
Admin
I love it when people put their name on source code. Even better, dated as well. All it needed was a signed bug fix somewhere.
Maybe one day we won't have a need for such things and software will track all changes and who made them for us
Admin
Could be worse. I misread the truncated title in my RSS feed as "Validating a date with Sleep()".
TRWTF is date formats in which "01/02/03" is a day in 2008.Admin
imagine how much fun this would be in lisp
Admin
Well I just go and type the two letters. On Windows, in a Combobox (HTML <select> element), opened or not, typing letters will select the first entry your typing matches. Always works for me.
Admin
Code ALWAYS needs comments - I add comments because the next monkey to look at tis code might be too stupid to understand what's going on. I hope the person before me adds comments, so that when they use clever short cuts I can actually understand what they are trying to acheive (perhaps more to the point, I hope the person before me comments code, because I don't trust them enough to have actually done things properly - I like them to document their intent - what the code does, and what the code was meant to do can be two seperate things. Saying "Any programmer should understand this code" ia all beaut and fine - but just because I can understand what a piece of code does, doesn't mean I can understand what a piece code is meant to do....)
I assume you were just being a tad facetious (that's shitful - from the latin: faeces) If, on the other hand you are serious, then to me it shows a severe lack of understnading of how the world works.
(I'll even say Comprehensive) Comments are imperative because: a) You don't know what monkey will need to maintain your code (and them not understanding it will be blamed on you) b) You can't trust the monkey who writes code you have to maintain actually knew what they were doing c) It makes it more readable for the non-techo (not always important - but a lot of managers like to think they can read well commented code, and understand that you ARE doing the job they hired you for) d) (Probably a paraphrase of b mixed with a) Just because it is bleedingly obvious (to you) what your code does, doesn't mean that it's obvious to someone else - -nor does it mean that it does what you intended....
Anywho, I'm off to eat some bananas
Admin
Hmmm...Now might be a great time to reopen the "Magic Numbers" debate..... Sure some languages have odd quirks in how they represent dates (Java has several date/calendar type classes that are a real mess - and are inconsistent with each other).... If the language chooses to represent February as 1, create a constant to represent February - then you don't need to worry about the number being out of sync....
This is why we avoid Magic Number, people....
Here endeth the lesson
Admin
I must disagree most vehemently..... Granted the code is checking that a value is less than 0 or greater than 3, but commenting it like that is EXACTLY what you are bagging ASM comments about above.... The comment explains (or attempts to explain) the purpose of the test - that is, to make sure we have a positive (oops, he missed that bit) value less than 4....
Comments should explain what is acheived (or attempt thereof) by that line, not exactly how the line does it.... You seem to realise this in your comments about comments in ASM ( ;move ax to bx....). Surely commenting this code as "Check whether value is less than 0 or greater than 3" is exactly the same mistake you highlight with the ASM. The comment there explains WHAT is being acheived not HOW it is being done (admittedly, it may be more useful to explain WHY we need to check this)...Sure, it's an obvious comment abut an obvious piece of code, bu comments are harmless....If you are "De Man" and can interpret the code (and the coders intentions) simply by staring at the code, feel free to ignore all comments.... You could always write a program to strip them all out for you, anyways (or find an IDE that allows you to fold them over nicely so they disappear)....
Admin
Tony B then moved on to his next project; creating a circular device that is capable of rotating on its axis to facilitate movement or transportation whilst supporting a load.
Admin
More to the point (and I'll crawl back under my rock If I'm wrong), can't you add a validator to a text box - so that it only allows valid things to be entered (ie validates the text AS it's entered.......)
Admin
It doesn't make sure we have a positive value, it makes sure that we have a character that is one of "0", "1", "2", or "3". We are comparing character values here, not numeric values.
Actually comments can be VERY harmful, especially if you read and TRUST only the comment. The problem with comments is they tend to get out of sync. If you get a piece of code, what is correct, the comment or the code? I'm not saying comments are bad, and that we shouldn't use them. But comments should be used sparingly. Well written code trumps a bad comment any day.Admin
I think they tried that in the French Revolution, but it didn't stick.
Actually, a 60-based time system has some advantages. You can easily divide 60 by 2, 3, 4, 5, 10, 20, and 30 without much thought. 100-minute horus would require more math.
Admin
Admin
What makes you think there are no unit tests? With one exception the code works, and works as designed. It is a bad design, and it is bad code. But it works.
The coder forgot about leap year. Why do you think he would have magically remembered if he had written the test first?
I'm going to say that the problem with leap years, for example, is only possible, because the coder FORGOT about leap years.
A good majority of the code we see here is broken. Sometimes a unit test would have found the problem, shoot sometimes just USING the product would have found the problem. But sometimes the code we get works. It is still WTFy code, and is still amusing to see.
WTFs happen because people are stupid. They happen in any language, and happen with any tools, or process. TDD is a WTF in itself, and will generate just as many, or more WTFs as non TDD.
Admin
Making the entry Read Only and relying on the datepicker is definitely a WTF.
I was at a hotel one time, and needed to check on my flight. I went to the website and was only able to use the datepicker. Unfortunately the time on the computer was off by about 5 years. Since I couldn't type in the date, nor change the time, my only option was to click through 60+ plus months!