• (cs) in reply to masklinn

    Woohoo, failed... god dammit, i must stop posting links on these forums, i usually manage to get it right for most things but never for links

  • (cs) in reply to Suck My Lisp

    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!

     

    Please be joking.  You're joking right?  Shit, I just don't know.  Man I hate JavaBeans.

  • Dan G (unregistered) in reply to Sean

    You know, you could at least try to make your goals plausible.

  • Anonymous (unregistered) in reply to Suck My Lisp

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

    Right! And another server to process and cache CountryCode beans.

     

  • Anonymous (unregistered) in reply to Suck My Lisp

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

    Right..... And another server to process and cache CountryCode beans.

     

  • (cs) in reply to Anonymous
    osp70:

    StringBuffer countryString = new StringBuffer(5000);

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

     



    What you don't understand is that the 'countryString' is not holding one country.  It is holding ALL of the countries.  The String being passed into this method is only there to have the passed in country selected.  Every country in the list gets appended to 'countryString'.  The if/else blocks are only there to pick the right one as selected.

    This method is getting the country dropdown for a web page, so this method is a small part of an html page being built as a large String with what looks like Java.

    I actually think the buffer will get maxed out, but that won't be a problem as it will simply increase it's capacity.

    The goggles they do nothing.
    My eyes are bleeding.
    It hurts, It burnsssss usss.

    Wow.
  • (cs)

    The problem is not that it is a WTF (who cares?), the problem is that it is full of bugs. Or maybe it was uncorrectly pasted. Or more probably retyped...

  • (cs) in reply to Anonymous
    Anonymous:
    Right! And another server to process and cache CountryCode beans.


    Zounds!   Excellent suggestion--I've been itching for a chance to implement a distributed second-level cache for Hibernate.  Complexity makes for robustity! JBoss TreeCache, here I come!
  • alan (unregistered)
    Alex Papadimoulis:
      <FONT color=#006400>//ED: Yes, contryOptions is a class-level field</FONT>
      countryOptions = countryString.toString();
      return countryOptions;
    }

    Yikes! THAT is the biggest F in this WTF!!

  • butch (unregistered) in reply to masklinn
    masklinn:
    Anonymous:
    Yikes! It ate my html! Why can't it just htmlentity it? :(

    Another attempt:
    <select> <option>US </option><option>UK </option></select>

    Well, this is perfectly valid HTML so it could indeed be written that way.



    IE spits chips if you don't explicilty set a value for each option.

    <select><option value="US">US</option></select>

    selectedIndex works but forget about .value, which sucks if ya looping all fields.

    I'm wearing panties.
  • JC (unregistered) in reply to masklinn
    masklinn:
    Anonymous:
    Yikes! It ate my html! Why can't it just htmlentity it? :(

    Another attempt:
    <select> <option>US </option><option>UK </option></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)



    According to the standards, no it is not (well, maybe at the loosest doctype, but even then, you're just being dead brained writing it so sloppy with the attributes unquoted and no closing tags).

    (HOW CUTE!!! When I quoted the post, it gave me a select box. This forum software is the most niftiest wtf I have seen. )
    [image][image][image][image][image][image]
  • (cs) in reply to JC
    JC:
    The site he was referring to is here. The comments refer to the w3 page on elements. In HTML block-level end tags are not required. Immediately after is the section on attributes. Depending on the characters used attributes do not have to have quote delimiters.

    I was as surprised as you.
  • (cs) in reply to mrsticks1982

    It's a twofer!

    Grammar rule for the new millenium:  AN APOSTROPHE DOES NOT MEAN "LOOK OUT!  HERE COMES AN S!''

    [pi]

  • Justin (unregistered) in reply to R.Flowers
    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.


    You forgot JavaScript.
  • (cs) in reply to DiamondDave
    DiamondDave:
    God forbid somebody passes a null string into this method....

    It would probably cause their network to go down...


    It would probably cause it to get, like, three feet of air.
  • (cs) in reply to Gene Wirchenko
    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



    At last! An explanation!

  • (cs)
    Alex Papadimoulis:

    ... sniped a whole bunch of countries ...

    Do you mean the entire population, or just the heads of state?

    Not that it makes much of a difference on Bouvet Island. :-D

    I would preview, and there's probably O(ln N) typos after the Polish porter I had, but what with the forum software and all...
  • Kiss me, I'm Polish (unregistered) in reply to rholliday

    Here comes Pippi Longstocking.

    XHTML is not valid HTML, if I remember correctly. And in HTML there are some amazing workarounds to make things work alright (closing the li tags for example). So don't try to find THE solution. There's no solution.
    I'm surprised though. Nobody (or maybe I'm just too tired today to see it through two pages of comments) pointed out the fact that every second item in the list of countries is SELECTED. That's almost all of them going into the "too much" section.

  • (cs) in reply to Kiss me, I'm Polish
    Anonymous:

     ..the fact that every second item in the list of countries is SELECTED..


    Not true. For example, if  isTrue(countryCode.equals("AJ")), part of the output would look like this:

    <OPTION value=AJ selected>Azerbaijan
    <OPTION value=BF>Bahamas
    <OPTION value=BA>Bahrain

    As always, the real wtf is the -insert fav wtf here-...


  • (cs) in reply to Dan G

    I wonder why the developer did............... never mind.

    I guess it's a good thing that he at least managed not to........... never mind.

    sigh

    Something's forcing me to comment on this, yet I am speechless.

  • (cs)

    I think the same guy who wrote this worked for me at one time :S

    He used to brag about his "brute force" approach to program design.

  • (cs) in reply to whitey
    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.
  • (cs) in reply to maratcolumn1

    (comments about forum software omitted)

    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.



    Well, you'd better learn some.

    1. Proper way: You can add all countries before selected one, then selected one, then all countries after selected one. Since your list is sorted, you can use binary search, or 26*26 elements lookup table.

    2. My way:

    int p = preparedCountryList.indexOf("<option val="+db_countryCode+ ">");

    if (p == -1) /* unthinkable mayhem */;

    return preparedCountryList.insert(" selected", p + 7) /* don't remember if Java have insert function or how it's called */;

  • (cs) in reply to zip
    zip:

    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!

     

    Please be joking.  You're joking right?  Shit, I just don't know.  Man I hate JavaBeans.



    JavaBeans is a condition arising from the consumption of far too much coffee.
  • (cs)

    I actually liked the "robust" solution; but, shouldn't there be Factory and Validator beans in there somewhere? 

    Of course, in addition to using EJBs, the need to work in some XML so that we can do an XSLT transform is obvious... after all, no matter the result of the transform, our resumes can always use the extra acronyms.

    The </OPTION> tags can always be added after the fact by implementing a DHTML solution.

  • (cs) in reply to whitey
    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.


    You use the strategy design pattern.
    In Java:
    interface CountryCodeable
    {
        String getCountry(String getCountryCode) throws NullPointerException; // or enumerate the country codes
    }

    ...then back the implementation using a java.util.Map with O(1) lookup, and potentially loading the strategy dynamically - in constrast to hard-coding it with O(n) lookup as it currently stands. I say java.util.Map with a foul taste in the back of my mouth - I much prefer properly designed collection types, which rules out java.util.*
    net.tmorris.adt.map.Map http://contractualj.com/api/net/tmorris/adt/map/Map.html
  • (cs)

    Is it me, or is this an MVC/Model 2 violation? WTF?

  • Brilliant! (unregistered)

    Way to throw a shout out to every country, I mean I don't think people spend enough time making sure to cover all of the bases.  Who cares that the page is going to be heavy. What's a few seconds shaved off some poor chumps life every time this page loads as long as you never get that call about uzbekistan not being in the drop down list.

  • (cs) in reply to Kiss me, I'm Polish
  • (cs) in reply to Kiss me, I'm Polish
    Anonymous:
    Here comes Pippi Longstocking.

    XHTML is not valid HTML, if I remember correctly. And in HTML there are some amazing workarounds to make things work alright (closing the li tags for example). So don't try to find THE solution. There's no solution.
    I'm surprised though. Nobody (or maybe I'm just too tired today to see it through two pages of comments) pointed out the fact that every second item in the list of countries is SELECTED. That's almost all of them going into the "too much" section.

    XHTML is roughly a subset of HTML with much stricter rules (being XML and all) such as being case-sensitive, disallowing attribute minimization (e.g. writing <option selected> instead of <option selected="selected">), forcing the quoting of attributes in every situations, requiring closing tags for every element, forbidding implied elements (e.g. writing only the <body> par of an HTML document is allowed, the browser has to generate the <html> root, <head> and <title> parts on his own, you can't do that in XHTML) ...

    This means that an XHTML (1.0 at least) document IS backwards-compatible with an HTML document, and is actually parsed as an HTML document in just about every browser now (sending your XHTML document with a "text/html" MIME type will always get it parsed as HTML no matter what you do, you're supposed to use "application/xhtml+xml" or "application/xml" to have it parsed as actual XHTML, and IE doesn't understand these BTW)

    HTML is an SGML dialect, meaning it has much looser constraints, therefore that the actual parsing and generation of the tree is much harder. See Ian Hickson's Crazy Tagsoup Parsing Adventures for some insight on how the current browsers fare at parsing HTML.

  • synonymous (unregistered) in reply to Cirdan
    Alex Papadimoulis:

    ... sniped a whole bunch of countries ...


    Yeah, this is really my only concern. We can't have deranged programmers running around sniping countries, but if I had to write out all the country names like that, I'd probably want to snipe something too...
  • Kiss me, I'm Polish (unregistered) in reply to masklinn
    masklinn:
    Anonymous:
    Here comes Pippi Longstocking.

    XHTML is not valid HTML, if I remember correctly. And in HTML there are some amazing workarounds to make things work alright (closing the li tags for example). So don't try to find THE solution. There's no solution.
    I'm surprised though. Nobody (or maybe I'm just too tired today to see it through two pages of comments) pointed out the fact that every second item in the list of countries is SELECTED. That's almost all of them going into the "too much" section.

    XHTML is roughly a subset of HTML with much stricter rules (being XML and all) such as being case-sensitive, disallowing attribute minimization (e.g. writing instead of ), forcing the quoting of attributes in every situations, requiring closing tags for every element, forbidding implied elements (e.g. writing only the par of an HTML document is allowed, the browser has to generate the root, and

    This means that an XHTML (1.0 at least) document IS backwards-compatible with an HTML document,


    No, it's not. You're assuming that xhtml is a subset of html - but it's not. There's no
    tag in html. There is no <?xml ?> mark at the beginning of a document in html. There is no lang attribute for the html element. That's what I'm talking about. XHTML has common points with HTML, but is not its subset.

    and is actually parsed as an HTML document in just about every browser now (sending your XHTML document with a "text/html" MIME type will always get it parsed as HTML no matter what you do, you're supposed to use "application/xhtml+xml" or "application/xml" to have it parsed as actual XHTML, and IE doesn't understand these BTW)

    That's the biggest difference between xhtml 1.0 and 1.1. Sending xhtml 1.1 as text/html means you (the general you, not the personal you) don't understand what it is. People should'nt actually use xhtml 1.1 at all, at least not in public.

    HTML is an SGML dialect, meaning it has much looser constraints, therefore that the actual parsing and generation of the tree is much harder. See Ian Hickson's Crazy Tagsoup Parsing Adventures for some insight on how the current browsers fare at parsing HTML.

    He's talking about html 5.0 and parsing a document with as many omitted tags as possible. No user agent renders it correctly? What a surprise.
  • Kiss me, I'm Polish (unregistered) in reply to Kiss me, I'm Polish

    Scheisse forum Zoftwar!
    One of the preceding paragraphs, take two:
    No, it's not. You're assuming that xhtml is a subset of html - but it's not. There's no <br /> tag in html. There is no <?xml ?> mark at the beginning of a document in html. There is no lang attribute for the html element. That's what I'm talking about. XHTML has common points with HTML, but is not its subset.

  • (cs) in reply to Kiss me, I'm Polish

    Please, don't try to teach me how html and xhtml work...

    That said

    Anonymous:

    No, it's not. You're assuming that xhtml is a subset of html - but it's not.

    Notice the "roughly" at the beginning of the text?

    Anonymous:

    There's no <br> tag in html.

    I beg your pardon?

    Anonymous:

    There is no mark at the beginning of a document in html.

    See above

    Anonymous:

    There is no lang attribute for the html element.

    Yeah right, please stop smoking, the root of an HTML element does have a lang attribute, what it doesn't have is an xml:lang attribute.

    Anonymous:

    That's what I'm talking about. XHTML has common points with HTML, but is not its subset.

    If you want to be picky about it, the precise definition of XHTML 1.0

    [...]is a reformulation of the three HTML 4 document types as applications of XML 1.0 [XML]. It is intended to be used as a language for content that is both XML-conforming and, if some simple guidelines are followed, operates in HTML 4 conforming user agents.

    The point is that if you follow the Compatibility Guidelines, XHTML 1.0 behaves, for all means and purposes, as a subset of HTML 4.01.

    Anonymous:

    That's the biggest difference between xhtml 1.0 and 1.1. Sending xhtml 1.1 as text/html means you (the general you, not the personal you) don't understand what it is. People should'nt actually use xhtml 1.1 at all, at least not in public.

    Yes and? Did I ever say anything different? Hell, did I EVER mention XHTML 1.1 in my post? Answer: no, I didn't, the only version mark I gave was 1.0

    Anonymous:

    He's talking about html 5.0 and parsing a document with as many omitted tags as possible. No user agent renders it correctly? What a surprise.

    How about reading TFA in the first place? He's doing tests of the current state of the parsers on HTML documents, he's not using any feature of HTML5, and while his experiment is part of his writing on error handling in HTML5, what he's using here is good ol' html 4 (or 3, or you could probably get as low as HTML 1.0 and it'd still be more or less correct), the point is not the rendering but the parsing abilities and error recovery of HTML parsers.

  • (cs) in reply to Kiss me, I'm Polish
    Anonymous:
    Scheisse forum Zoftwar!
    One of the preceding paragraphs, take two:
    No, it's not. You're assuming that xhtml is a subset of html - but it's not. There's no
    tag in html. There is no mark at the beginning of a document in html. There is no lang attribute for the html element. That's what I'm talking about. XHTML has common points with HTML, but is not its subset.

    Well, let's answer that too:

    <br /> tag
    HTML has a <br> tag, the only difference is that XHTML, being XML, requires you to close empty elements while HTML forbids it. If you really want to go for that kind of stupidity, you can also say that HTML doesn't have an <img /> tag either, which is just as wrong.
    <?xml ?>

    Guess what? The XML declaration is optional, even in fully conforming XML documents, and it certainly is not required in both XHTML 1.0 and in XHTML 1.1

    Encouraged? yes. Required? no. No one therefore cares wether HTML documents have it or not

    lang attribute
    Already pointed that one, the html element of an HTML 4.01 document does have a lang attribute.
  • (cs) in reply to masklinn

    Gah, let's try it again.

    Anonymous:
    Scheisse forum Zoftwar!

    One of the preceding paragraphs, take two:

    No, it's not. You're assuming that xhtml is a subset of html - but it's not.

    • There's no <br> tag in html.
    • There is no <?xml ?> mark at the beginning of a document in html.
    • There is no lang attribute for the html element.

    That's what I'm talking about. XHTML has common points with HTML, but is not its subset.

    Well, let's answer that too:

    <br> tag
    HTML has a <br> tag, the only difference is that XHTML, being XML, requires you to close empty elements while HTML forbids it. If you really want to go for that kind of stupidity, you can also say that HTML doesn't have an <img /> tag either, which is just as wrong.
    <?xml ?>

    Guess what? The XML declaration is optional, even in fully conforming XML documents, and it certainly is not required in both XHTML 1.0 and in XHTML 1.1

    Encouraged? yes. Required? no. No one therefore cares wether HTML documents have it or not

    lang attribute
    Already pointed that one, the html element of an HTML 4.01 document does have a lang attribute.
  • (cs) in reply to masklinn

    oooh, definition lists don't work at all... well at least i'll know it for the next try.

    Let's try with some deflist emulation then, maybe the forum'll stop mangling it, third time's the charm or so they say

    Anonymous:
    Scheisse forum Zoftwar!

    One of the preceding paragraphs, take two:

    No, it's not. You're assuming that xhtml is a subset of html - but it's not.

    • There's no <br> tag in html.
    • There is no <?xml ?> mark at the beginning of a document in html.
    • There is no lang attribute for the html element.

    That's what I'm talking about. XHTML has common points with HTML, but is not its subset.

    Well, let's answer that too:

    • <br> tag

      HTML has a <br> tag, the only difference is that XHTML, being XML, requires you to close empty elements while HTML forbids it. If you really want to go for that kind of stupidity, you can also say that HTML doesn't have an <img /> tag either, which is just as wrong.

    • <?xml ?>

      Guess what? The XML declaration is optional, even in fully conforming XML documents, and it certainly is not required in both XHTML 1.0 and in XHTML 1.1

      Encouraged? yes. Required? no. No one therefore cares wether HTML documents have it or not

    • lang attribute

      Already pointed that one, the html element of an HTML 4.01 document does have a lang attribute.

  • haz (unregistered)

      <FONT color=#0000ff>if</FONT>(countryCode.equals("WTF"))
        countryString.append("<OPTION value=WTF selected>What the Fuck");
      else
        countryString.append("<OPTION value=WTF >What the Fuck");

  • (cs) in reply to Suck My Lisp

    And that's the very reason EJB 2.0 was a resounding failure. And why POJOs are recommended over entity beans. Now EJB 3.0 has learnt from the drawbacks of EJB 2.0. Obviously, the .NET Framework has made EJB run for its money.

    I know of numerous organisations that had baulked at using EJB and instead opted for the .NET Framework. I know because I worked for one. They looked at EJB 2.0 and got feedback from the local EJB community, did their maths and found it not only prohibitively costly to port to EJB from an old Sun platform, they found most disconcerting the complexity in terms of creating and deploying these beans across the board.

    Was way easier to use .NET Remoting Services and NHibernate to provide a robust solution with one-tenth the cost of going EJB 2.0.

    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!

  • Barefoot (unregistered)

    Aaaaahhh! My EYES! The glasses! They do nothing! :'(
    I'm BLIND!

  • (cs) in reply to Barefoot
    Anonymous:
    Aaaaahhh! My EYES! The glasses! They do nothing! :'(
    I'm BLIND!

    You fail at using memes, the goggles do nothing, no glasses involved.

    Proof:

    <img src="http://masklinnscans.free.fr/4chan/Magic/goggles.gif" alt="The goggles, they do nothing>
  • (cs)

    GeeWiz,   just "SOAP" that sucker to the appropriate Geo-Political, Date-Time, Language-Babel, Travel-Guide, Global-Mapping, Gimme-Directions, Reverse-Finding, Census-Data, Atomic-Clocking, Currency-Converting, Stock-Quoting, Best-Fare, Shop-For-Me, Think-For-Me, Do-My-HomeWork, Find-My-Class-Mates, In-My-Opionion, Rumor-Mill, News-Line, Wiki-Bloggy, Trade-Anything, Try-For-Free, Industry-Trending, High-Tech, Base-Logic, New-Theory, Some-Day-In-History, Jokes-N-Quotes, Media-Clip, Book-Review, Ring-Tone-Library or You-Name-It-We-Found-It" webservice.

    Surely the data is out there. No need to hard-code all that stuff.

  • (cs) in reply to Anon
    Anonymous:
    F1rst!

    I've been too busy to check in with TDWTF and when I finally get a few seconds of tranquility, this is the first post I'm greeted with.

    Anonymous, you are an asshole. You are a complete waste of carbon. Would you please kindly die so that the rest of us may benefit by your absence?

    Anonymous:
    WTF

    And you're not much better. Thanks for the insightful and original contribution. Why even bother?

    ahhhh. I feel so clean now...
  • (cs) in reply to Suck My Lisp
    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,


    Nitpick: if you implement it yourself, it's bean-managed, not container-managed persistence.

    Otherwiese: ROTFL
  • (cs)

    maybe it's paid by line of code

  • panzi (unregistered)

    if(countryCode.equals("AT"))
    countryString.append("Ashmore and Cartier Islands");
    else
    countryString.append("Ashmore and Cartier Islands");
    if(countryCode.equals("AS"))
    countryString.append("Australia");
    else
    countryString.append("Australia");
    if(countryCode.equals("AU"))
    countryString.append("Austria");
    else
    countryString.append("Austria");

    I thought the country code for austria is at?
    Hmm, well that's confusing. Look at the codes of austria and australia:
    http://en.wikipedia.org/wiki/Country_codes:_A#Australia

  • Interesting (unregistered) in reply to codermeta
    codermeta:
    maybe it's paid by line of code


    Did you reaaly register just to say that?


  • anonymous (unregistered)

    You guys don't get it? It's optimized for sorting!

  • (cs) in reply to felix

    XHTML is a subset of SGML.
    HTML is a subset of SGML, not SGML in itself.

    Apart from that, there's no formal relationship between HTML and XHTML.
    XHTML certainly is NOT a subset of HTML. Tell me in which formal documentation, which page and paragraph is it explicitly stated that XHTML is a subset of HTML.

    You should really have a good look at the real picture.

    felix:
  • (cs) in reply to whitey

    whitey:
    curious, how would you solve this?

    SELECT all country codes from DB
    LOOP through them and say
        PRINT "<OPTION ? + selected?) val="+db_countryCode+(countryCode&#13;&#10;== db_countryCode ? ">

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

    There is one way to avoid if()*N, but its not faster and uses more memory.

    Basically, write the whole string WITHOUT the select. Then go back into the string searching for the country code you need and insert the "select" text-- however, this causes the string to have to be reallocated since you're increasing it's size. If you were writing in a proper language like C/C++ you could allocate the given size ahead of time and only have to take the time hit for moving the characters over (and not for re-allocating memory) but its still not faster since you're a) moving chars and b) doing a string search. if()*N really is the fastest way.

Leave a comment on “It's a Small World Afterall”

Log In or post as a guest

Replying to comment #:

« Return to Article