| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
I believe I am being only slightly offtopic when I ask if anyone knows how to stop bleeding from the eyes.
|
|
Well, let's see... we could have a table in the database that lists the country codes and country names, but loops and DB access just slow down the system, so yeah, this is the best way to do it.
Not! |
|
Talk about getting paid per line
|
|
I'm looking forward to the whole mess of "it looks OK to me, obviously this code is machine generated, so that's not a WTF" posts ....
|
|
Good thing this was written AFTER the fall of the Soviet Union. Although the thought of an application being taken down due to the formation of Kazakhstan amuses me for some reason.
|
Re: It's a Small World Afterall
2006-01-20 14:07
•
by
ChiefCrazyTalk
|
|
Ummm...we get the point - don't you think you could have snipped a few more lines of the code? [:D]
|
|
I thought the same thing myself. I was also disappointed to see that Trinidad and Tobago was snipped :-( |
Re: It's a Small World Afterall
2006-01-20 14:14
•
by
another guy
|
It looks OK to me, obviously this code is machine generated, so that's not a WTF |
Re: It's a Small World Afterall
2006-01-20 14:15
•
by
SweetFancyMoses
|
|
Well clearly the two problems were unrelated, the op was just illustrating how fragile the system really was. And hasn't somebody already yelled at you for signing your posts? Boilerplate sincerity is anything but.
|
|
Well, <OPTION value=US> should be <option value="US">, but at least he has the </OPTION>
|
|
God forbid somebody passes a null string into this method....
It would probably cause their network to go down... |
Re: It's a Small World Afterall
2006-01-20 14:17
•
by
diaphanein
|
If it wasn't machine generated at least we'll be sure that this "developer" will have a short career due to acute carpal tunnel syndrome. |
|
Is this an example of the "loop unrolling" I've been hearing about?
Agreed. Is it added to the list yet?
|
|
I'd like to know where he got his ISO-3166 list of countries as
practically all of the country codes shown aren't valid ISO-3166 codes. At least he got the code for Bouvet Island correct. Shame no-one lives there! |
Which brings up another thought: woe to the user that actually clicks on/pulls down this menu! |
There's machine generated and machine generated... If you never see the code that's spit out by the machine (another issue) and you trust the generator (yet another), well, maybe. This looks like he used a Perl script to generate it and then pasted it in. On the bright side, he might've kept the Perl script(s) around in case any new countries popped up. |
|
No... Nooo! Nooooooooooooooooo!!!!!111!!!!omgWTF
Ze goggles, zey do nossink... |
|
curious, how would you solve this?
SELECT all country codes from DB LOOP through them and say PRINT "<option val="+db_countryCode+(countryCode == db_countryCode ? " selected") + ">"+db_countryName+"</option> can't see an efficient way to avoid the if statement num(countries_in_db) times. |
If there's one thing the readers of this site are good at, it's beating the hell out of a joke. Next goal: kiss an actual girl. |
|
Not to mention that the method is called "getCountry", which isn't what it does, and it uses a local variable to store the raw HTML, which is then put into a class-level string, which is then returned for some reason... I guess he's really worried about losing that variable.
--YY |
|
I'd like to know where he got his ISO-3166 list of countries as practically all of the country codes shown aren't valid ISO-3166 codes. you didn't get that.. he updated the *database* that code was old and broke following the update |
|
Also observe Belgium can't be selected; Belarus appears twice instead: if(countryCode.equals("BE")) This also suggests it's not machine-generated... |
Re: It's a Small World Afterall
2006-01-20 14:38
•
by
another guy
|
|
It's an ideal solution for an environment where database server is often unavailable. It also provides ultimate job security. So, hardcoding stuff is always a good idea any way you look at it. |
|
> Well, <OPTION value=US> should be <option value="US">, but at least he has the </OPTION>
actually, no, he hasn't.. he has <option value=xx>XXX <option value=yy>YYY ...... </option> |
|
Well, you could do...
then (non-code lang specific)...Not uber pretty, but, it works! |
|
ugh...
Well, you could do... <code to generate the select...> then (non-code lang specific)...
<script> Not uber pretty, but, it works! |
Re: It's a Small World Afterall
2006-01-20 14:48
•
by
another guy
|
Oh! That's very common for machine to confuse the 2. See, machines, unlike us humans, are very stupid, and need to be told what to do. Machine can't necessary tell that BE = Belgium and Belarus are 2 different countries. And that's also the reason why captcha never works the first time.
|
Re: It's a Small World Afterall
2006-01-20 14:54
•
by
Anonymoose
|
Chop your legs off. The bleeding from your eyes will subside shortly after. |
Actually, most of those codes are valid--it's just that only about half of them are assigned to the correct place. Looks like the kind of thing I see when I try to sort two columns of a spreadsheet, and only one of them actually sorts. Captcha: "platinum" as in, "I made Platinum with my airline flying around to retrieve all those misdirected packages...) |
Re: It's a Small World Afterall
2006-01-20 15:08
•
by
Gene Wirchenko
|
Canada, sob, was snipped. Second largest country in the world and it got snipped. It is not fair. set ownoxgored off (Though I live in the USA, I am Canadian.) Sincerely, Gene Wirchenko |
Re: It's a Small World Afterall
2006-01-20 15:10
•
by
John Bigboote
|
The way I figure it, the less strain you put on the data tier, the better. As strain approaches zero, the awesomeness of your application approaches infinity. |
That's why you are so polite, eh? Do you get to vote in Monday's election? |
God, I HATE how wrong people can get writing something as html!!! Every day in my work I get to work with html that has no doctype ("Oh, doctypes aren't required, so no need to use it... just takes up bandwidth!"), has multiple sections ("I changed the title but it won't update, WHY!?"), and "hey, html needs no closing tags duz it?". :( As such, I would not be suprised at all these days to see: Anyway, the real wtf here is that he used html for the drop down list rather than a flash object or java applet. |
|
Yikes! It ate my html! Why can't it just htmlentity it? :(
Another attempt: <SELECT> <OPTION>US <OPTION>UK </SELECT> |
|
How ugly. The correct way to do it is to create a database table
which contains country codes and country names. Then, create an entity bean encapsulating those two fields. Use your favorite object-relational mapping tool to implement some sort of container-managed persistence, and create a session bean that you can use to get the list of country codes. Now, we might want to change the back-end country code implementation someday, so from there we need to create a CountryCodeConnector interface that returns objects that implement the CountryCodeProvider interface. After writing implementations for those two classes that use our beans, we simply plug our implementation for the connector into a service locating framework in our J2EE Server. Spring seems popular. Then, when we want to create a drop-down list of countries for our users, all we need to do is user the framework to get the connector to get the provider to get the beans, copy the values over into Strut's "LabelValueBean"s. We'll stick all the LabelValueBeans into a list, attach it to the request in the action serving the form, and then we can simply use the html:optionsCollection tag to create the list! For only a little more code then today's "WTF", we'll have a robust solution! |
Re: It's a Small World Afterall
2006-01-20 15:29
•
by
mrsticks1982
|
Why is there someone who has to try an solve these WTF's. Come on all WTF have a better solution. Just have a good laugh and enjoy the opportunity to take a few minutes to sigh and now that you are smarter than them. *sigh* - Thanks to the programmer who made me feel better about myself today!! |
|
I can't really come up with a worse way to do this. I'm trying...Maybe if you just put all the country names into one loooong string, then iterated through it one character at a time, stopping if you got to a country that matched the request? Meh. Doubt that would even work.
I thought I knew what conditional hell was, but this takes the cake. Jesus Christ, he could have at least used a case statement! I would have said an array, but an array is too good for this guy. I can't believe the monkey is working in Java as well...My god. Object oriented code, fool! |
Re: It's a Small World Afterall
2006-01-20 15:30
•
by
mrsticks1982
|
sweet I love when I have typo's!!!! |
Re: It's a Small World Afterall
2006-01-20 15:33
•
by
warispeace
|
We have some garbage like this wtf in our old asp pages. In .NET it's much easier though: ddlvar.SelectedValue = "en_US"; |
do what now? ;) |
|
StringBuffer countryString = new StringBuffer(5000); I love this, but would kill to see the country that will max out this buffer.
|
Re: It's a Small World Afterall
2006-01-20 15:48
•
by
ChiefCrazyTalk
|
LOL Good eye! |
Re: It's a Small World Afterall
2006-01-20 15:49
•
by
John Bigboote
|
Nullpointeristan? |
WOW! All these to create a simple drop-down list of countries! Will your implementation require a dedicated server? Over engineering at its finest. |
Re: It's a Small World Afterall
2006-01-20 16:08
•
by
Suck My Lisp
|
*A* dedicated server? What kind of pedestrian architecture is that? We'll need one server for the database, one server for the EJB's, and another for the web app. And that's if we're not going to have any redundancy. If this is an important application, we should probably have a cluster of some sort. Maybe a few, just to be safe. |
|
He saved precious memory by eliminating the need for an iteration variable, simply genius!
|
Well, this is perfectly valid HTML so it could indeed be written that way. In fact, but for the uppercasing, that's exactly how Anne van Kesteren's HTML code is written, and the guy (yes, it's a guy) is smart enough to know why he wrote it that way (you would probably be able to find his reasons somewhere in his archives) |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |