Comment On It's a Small World Afterall

Everyone at Mark's company knew about the Resource Allocation system. To say the least, it was a mess of a Java servlets held together with batch files, spreadsheets, and chewing gum, all developed by programmers who have long since been promoted to Lead Architect and Management roles. A slight change of winds was all that was needed to start a chain reactions of bugs: a while back, an edit to the configuration file to change the notification email address caused the system to bring down the email servers with a loop that became infinite when the config-file value didn't match the hard-coded value. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: It's a Small World Afterall

2006-01-20 14:00 • by Anon
F1rst!

Re: It's a Small World Afterall

2006-01-20 14:02 • by WTF
57299 in reply to 57298
WTF

Re: It's a Small World Afterall

2006-01-20 14:02 • by SeekerDarksteel
I believe I am being only slightly offtopic when I ask if anyone knows how to stop bleeding from the eyes.

Re: It's a Small World Afterall

2006-01-20 14:02 • by jmeyer43

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!

Re: It's a Small World Afterall

2006-01-20 14:02 • by Monday
Talk about getting paid per line

Re: It's a Small World Afterall

2006-01-20 14:03 • by Jeff S
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 ....


Re: It's a Small World Afterall

2006-01-20 14:04 • by Sean
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
57305 in reply to 57304
   Ummm...we get the point - don't you think you could have snipped a few more lines of the code? [:D]

Re: It's a Small World Afterall

2006-01-20 14:10 • by Gene Wirchenko
Alex Papadimoulis:
a while back, an edit to the configuration file to change the notification email address caused the system to bring down the email servers with a loop that became infinite when the config-file value didn't match the hard-coded value.

public String getCountry(String countryCode)
{
StringBuffer countryString = new StringBuffer(5000);
countryString.append("Please select country");
if(countryCode.equals("US"))
countryString.append("United States");
else
countryString.append("United States");
if(countryCode.equals("AF"))
countryString.append("Afghanistan");
else
countryString.append("Afghanistan");
if(countryCode.equals("AL"))
countryString.append("Albania");
else
countryString.append("Albania");

 
Very impressive. Not using loops caused an infinite loop.

Sincerely,

Gene Wirchenko

Re: It's a Small World Afterall

2006-01-20 14:12 • by haveworld
57309 in reply to 57305
Anonymous:
   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
57310 in reply to 57303

Jeff S:
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 ....



 


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
57311 in reply to 57307
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.

Re: It's a Small World Afterall

2006-01-20 14:15 • by s0be
Well, <OPTION value=US> should be <option value="US">, but at least he has the </OPTION>

Re: It's a Small World Afterall

2006-01-20 14:17 • by DiamondDave
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
57314 in reply to 57303

Jeff S:
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 ....


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.

Re: It's a Small World Afterall

2006-01-20 14:22 • by R.Flowers

Is this an example of the "loop unrolling" I've been hearing about?


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 ....


Agreed. Is it added to the list yet?



  • The goggles...

  • The real WTF here is...

  • Damn *%!@^ forum software!

  • This code tastes like burning...

  • Brillant!

  • He should have used isTrue in there somewhere...

  • etc.

Re: It's a Small World Afterall

2006-01-20 14:25 • by Paul Abraham
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!



Re: It's a Small World Afterall

2006-01-20 14:26 • by R.Flowers
57319 in reply to 57305

Anonymous:
   Ummm...we get the point - don't you think you could have snipped a few more lines of the code? [:D]


Which brings up another thought: woe to the user that actually clicks on/pulls down this menu!

Re: It's a Small World Afterall

2006-01-20 14:28 • by JBL
57320 in reply to 57314
Anonymous:

Jeff S:
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 ....


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.



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.

Re: It's a Small World Afterall

2006-01-20 14:28 • by Danimal
No... Nooo! Nooooooooooooooooo!!!!!111!!!!omgWTF



Ze goggles, zey do nossink...

Re: It's a Small World Afterall

2006-01-20 14:33 • by whitey
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.

Re: It's a Small World Afterall

2006-01-20 14:33 • by Sean
57324 in reply to 57316
R.Flowers:

Is this an example of the "loop unrolling" I've been hearing about?


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 ....


Agreed. Is it added to the list yet?



  • The goggles...

  • The real WTF here is...

  • Damn *%!@^ forum software!

  • This code tastes like burning...

  • Brillant!

  • He should have used isTrue in there somewhere...

  • etc.


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.

Re: It's a Small World Afterall

2006-01-20 14:34 • by YodaYid
57325 in reply to 57319
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

Re: It's a Small World Afterall

2006-01-20 14:37 • by The doc
57326 in reply to 57318

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

Re: It's a Small World Afterall

2006-01-20 14:37 • by mark
57327 in reply to 57314

Also observe Belgium can't be selected; Belarus appears twice instead:


  if(countryCode.equals("BE"))
    countryString.append("


This also suggests it's not machine-generated...

Re: It's a Small World Afterall

2006-01-20 14:38 • by another guy
57328 in reply to 57312

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.

Re: It's a Small World Afterall

2006-01-20 14:40 • by The doc
57329 in reply to 57312
> 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>

Re: It's a Small World Afterall

2006-01-20 14:45 • by Gordo
57331 in reply to 57323
Well, you could do...

then (non-code lang specific)...




Not uber pretty, but, it works!

Re: It's a Small World Afterall

2006-01-20 14:46 • by Gordo
57332 in reply to 57331
ugh...

Well, you could do...



&lt;code to generate the select...&gt;



then (non-code lang specific)...

&lt;script&gt;
var f = document.forms[
document.forms.length -1];
var e = f.elements[f.elements.length -1];
e.value = $countryCode$;
&lt;/script&gt;






Not uber pretty, but, it works!




Re: It's a Small World Afterall

2006-01-20 14:48 • by another guy
57333 in reply to 57327
Anonymous:

Also observe Belgium can't be selected; Belarus appears twice instead:


  if(countryCode.equals("BE"))
    countryString.append("


This also suggests it's not machine-generated...



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
57334 in reply to 57300
SeekerDarksteel:
I believe I am being only slightly
offtopic when I ask if anyone knows how to stop bleeding from the
eyes.




Chop your legs off.  The bleeding from your eyes will subside shortly after.

Re: It's a Small World Afterall

2006-01-20 14:59 • by silverpie
57335 in reply to 57318

Paul Abraham:
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!


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
57336 in reply to 57309
haveworld:
Anonymous:
   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 :-(


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
57337 in reply to 57328
Anonymous:

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.





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.

Re: It's a Small World Afterall

2006-01-20 15:15 • by OneFactor
57338 in reply to 57336

Gene Wirchenko:
haveworld:
Anonymous:
   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 :-(


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


That's why you are so polite, eh? Do you get to vote in Monday's election?

Re: It's a Small World Afterall

2006-01-20 15:24 • by JC
57339 in reply to 57329
Anonymous:
> Well, should be , but at least he has the

actually, no, he hasn't.. he has XXX YYY ......


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.

Re: It's a Small World Afterall

2006-01-20 15:25 • by JC
57341 in reply to 57339
Yikes! It ate my html! Why can't it just htmlentity it? :(

Another attempt:

<SELECT>
 <OPTION>US
 <OPTION>UK
</SELECT>

Re: It's a Small World Afterall

2006-01-20 15:27 • by Suck My Lisp
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
57344 in reply to 57323

whitey:
curious, how would you solve this?

SELECT all country codes from DB
LOOP through them and say
    PRINT "


 


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!!

Re: It's a Small World Afterall

2006-01-20 15:30 • by Satanicpuppy
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
57346 in reply to 57344
mrsticks1982:

whitey:
curious, how would you solve this?

SELECT all country codes from DB
LOOP through them and say
    PRINT "


**EDITED**


Why is there someone who has to try an solve these WTF's. Come on, all WTF's have a better solution. Just have a good laugh and enjoy the opportunity to take a few minutes to sigh and know that you are smarter than them.


*sigh* - Thanks to the programmer who made me feel better about myself today!!



 


sweet I love when I have typo's!!!!

Re: It's a Small World Afterall

2006-01-20 15:33 • by warispeace
57347 in reply to 57323
whitey:
curious, how would you solve this?



SELECT all country codes from DB

LOOP through them and say

    PRINT ""+db_countryName+"



can't see an efficient way to avoid the if statement num(countries_in_db) times.


We have some garbage like this wtf in our old asp pages.  In .NET it's much easier though:  ddlvar.SelectedValue = "en_US";


Re: It's a Small World Afterall

2006-01-20 15:44 • by pbounaix
57348 in reply to 57324
Sean:
R.Flowers:

Is this an example of the "loop unrolling" I've been hearing about?


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 ....


Agreed. Is it added to the list yet?



  • The goggles...
  • The real WTF here is...
  • Damn *%!@^ forum software!
  • This code tastes like burning...
  • Brillant!
  • He should have used isTrue in there somewhere...
  • etc.



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.


 


do what now? ;)

Re: It's a Small World Afterall

2006-01-20 15:46 • by osp70

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
57350 in reply to 57327
Anonymous:

Also observe Belgium can't be selected; Belarus appears twice instead:


  if(countryCode.equals("BE"))
    countryString.append("


This also suggests it's not machine-generated...



 


LOL Good eye!

Re: It's a Small World Afterall

2006-01-20 15:49 • by John Bigboote
57351 in reply to 57349
osp70:

StringBuffer countryString = new StringBuffer(5000);


I love this, but would kill to see the country that will max out this buffer.


 





Nullpointeristan?

Re: It's a Small World Afterall

2006-01-20 16:03 • by Anonymous
57352 in reply to 57342

Suck My Lisp:
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!


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
57353 in reply to 57352
Anonymous:
WOW! All these
to create a simple drop-down list of countries! Will your
implementation require a dedicated server?



Over engineering at its finest. 


*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.

Re: It's a Small World Afterall

2006-01-20 16:14 • by Mr. Variable
He saved precious memory by eliminating the need for an iteration variable, simply genius!

Re: It's a Small World Afterall

2006-01-20 16:22 • by masklinn
57358 in reply to 57341
Anonymous:
Yikes! It ate my html! Why can't it just htmlentity it? :(

Another attempt:

<SELECT>

<OPTION>US

<OPTION>UK

</SELECT>

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)


« PrevPage 1 | Page 2 | Page 3Next »

Add Comment