• (unregistered)

    Worst kind of OO is the clueless OO.

  • (unregistered)

    I don't know about .Net 1.1, but in 1.0 the generic containers are ArrayList, Hashtable and SortedList - practically nothing. Not even a linked list. In comparison, Java has ArrayList, LinkedList, HashMap, HashSet, TreeMap and TreeSet, LinkedHashMap and LinkedHashSet. And some older containers with essentially the same functionality as some of the new ones.

    So yes, the programmer certainly had a lot to choose from.

  • (unregistered) in reply to

    <font face="Tahoma" size="2">System.Collections.Specialized Namespace

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsspecialized.asp

    HybridDictionary
    ListDictionary
    NameValueCollection
    StringCollection
    StringDictionary
    BitVector32
    </font>

  • mugs (cs)

    OK, usually the google ads make some sort of sense, but where do they come up with the idea that we'd want to order the "Entire Holy Zohor on Microfilm" or hire thousands of classical musicians?

  • (unregistered)

    <FONT style="BACKGROUND-COLOR: #efefef">I used to see this kind of thing all the time in my college VB6 (don't ask) course.  People found out about the list objects in VB and started putting everything in there.  We had to have a special review class about arrays and introduce collections about three weeks early to stop people from doing this.</FONT>

  • martinm1000 (cs)

    Ok, the example is in Java...

    Some explanations for other people :

    The JList is in the javax.swing package, which is the Swing GUI package for graphical components ;-)

    Actually, I'm not even sure if this code would work, as some GUI components would throw a HeadlessException exception if there is no Display on the computer (think server). Maybee it would works because there is no setVisible(true) called on the JList ;-)

    In Java, the collections (Maps, Lists and Sets) are mostly in the java.util package, and they have to implement the java.util.Collection interface.

  • (unregistered) in reply to martinm1000

    Actually, java.util.Map doesn't implement java.util.Collection, as Collection is really meant only for non-associative containers (though Set, which in the C++/STL world would be considered an associative container does in fact implement Collection).  If you look at Collection's methods, it's pretty clear that implementing it for Map would be hard.  For instance, how do you implement iterator() or add(Object) or remove(Object) for a Map?

    (Ooh, I think there are some more nits I can pick over here... :))

  • Rank Amateur (cs)

    Am I seeing this right? The only reason to use the JList at all is to get a count of the number of ATMTrafficDescr’s? And then the first loop stuffs the JList elements back into an array of ATMTrafficDescr’s? And the only thing the count is needed for is to iterate through the ATMTrafficDescr array to select some strings? Even I would think there has to be a way to iterate through the ATMTrafficDescr list directly. And I’m one of those VB programmers the 4th anonymous poster is talking about who has used a list box control as a substitute linked list!

     

    --RA

     

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> 

  • codeman38 (cs) in reply to mugs
    mugs:
    OK, usually the google ads make some sort of sense, but where do they come up with the idea that we'd want to order the "Entire Holy Zohor on Microfilm" or hire thousands of classical musicians?

    Heh. I'm surprised the Google ads didn't include an ad for jlist.com-- it's a site that sells bizarre Japanese pop-culture goods, but you'd think it would've come up considering the Java object being discussed. :)
  • Sean Reilly (cs)

    I'm also a java programmer, so for the record, here's how you do this when your head isn't shoved firmly between your own buttcheeks (I'm using Java 4 syntax, it would be slightly different in Java 5).

    List atmTrafficDescrsList = DataStore.getObjectList("ATMTrafficDescr");
    String[][] data = new String[atmTrafficDescrsList.length()][2];
    

    int j = 0; for (final Iterator i = atmTrafficDescrsList.iterator(); i.hasNext();) { final ATMTrafficDescr temp = (ATMTrafficDescr) i.next(); if (temp.getEnabled() && temp.getServiceClas().equals("CBR")) //I'm preserving a stupid bug here { data[j][0] = temp.getName(); data[j][1] = temp.getPcr(); } }

    The stupid bug I'm referring to in the comments has to do with how array initialization in Java.  Any time that the if statment fails and data isn't added to the data array, then the array elements at that index are left to null.  In other words, many nasty null pointer exceptions at runtime.<FONT style="BACKGROUND-COLOR: #efefef">  The best way to fix that would be to insert the following code before int j is declared:</FONT>

    for (final Iterator i = atmTrafficDescrsList.iterator(); i.hasNext();)
    {
        final ATMTrafficDescr temp = (ATMTrafficDescr) i.next();
        if (temp.getEnabled() && temp.getServiceClas().equals("CBR"))
        {
            i.remove();
        }
    }
    

    Once this is added the if statement in the original loop isn't neccessary any more.

    All in all, this is one of the most criminal abuses of the java language I have seen, ever.

  • Jeremy Morton (cs) in reply to Sean Reilly
    Sean Reilly:

    All in all, this is one of the most criminal abuses of the java language I have seen, ever.

    Agreed, but I wanted to point out that you missed incrementing j in your code.

  • (unregistered) in reply to Jeremy Morton
    Jeremy Morton:
    [image] Sean Reilly wrote:

    All in all, this is one of the most criminal abuses of the java language I have seen, ever.

    Agreed, but I wanted to point out that you missed incrementing j in your code.

    Dammit!  So I did.

  • cjs (cs) in reply to Sean Reilly

    Hm. Cool. So let's see how you'd do it in Ruby.

    <font face="Courier New">cbr_descrs = DataStore::get_object_list("ATMTrafficDescr").select { |d|
        d.enabled? && d.service_class == "CBR" }
    data = cbr_descrs.collect { |d| [ d.name, d.pcr ] }
    </font>

  • V. (cs)

    Although cheating by using GUI components where they're not needed is quite often used, this one does seems very, very strange to me.

    And why would you use the DataStore object to copy to an array, when you already put the DataStore in a JList?
    And why would you copy that array again in a string array?

    Is there some info we need to know, why anyone would do it like that, else wtf. [:)]

  • (unregistered) in reply to cjs

    This one actually made me cringe. Haven't seen this kind of abuse in a long time (fortunately).
    Here's the Python way of doing it:

    atmTrafficDescrsList = DataStore.getObjectList("ATMTrafficDescr")
    data = [(d.getName(), d.getPcr()) for d in atmTrafficDescrsList if d.getEnabled() and d.getServiceClass() == 'CBR']
  • (unregistered)

    In 16 bit VB a common way to sort a list of items was to use a hidden list box with the Sorted property set to True.  Now there's a wtf.

  • (unregistered)

    I get 2 google ads for G-Strings at the top of my page [:D]

  • nickelarse (cs) in reply to

    I get tactile metal domes.

    Anyway, nobody has mentioned this yet, so is it my responsibility to mention that surely the real WTF is that the opening braces are not on the next line?  Actually, I couldn't care less, but I feel someone had to mention it.

    As for the abuse of JList.  Well, yep, seems pretty bad.  I would have used a JTable myself, and a custom TableModel [;-)].  Though you could argue it shows imagination and creativity.

  • AndrewVos (cs)

    hey i don get google ads, not that im complaining!!

  • (unregistered) in reply to nickelarse
    nickelarse:
    Anyway, nobody has mentioned this yet, so is it my responsibility to mention that surely the real WTF is that the opening braces are not on the next line?  Actually, I couldn't care less, but I feel someone had to mention it.

    Of course not, because that's the One True Brace Style, which all code should use.  The real WTF is actually the missing space between the ) and the { characters.

  • Romeo-Gresta (cs)

    <font style="font-size: 10px; font-family: verdana,arial,sans-serif; color: rgb(0, 0, 0); line-height: 12px;" size="3">Seems like we're dealing another kind of Strings for Google:

    </font><font style="font-size: 11px; font-family: verdana,arial,sans-serif; line-height: 14px;" size="3">Guitar strings</font><font size="3">
    </font><font style="font-size: 10px; font-family: verdana,arial,sans-serif; color: rgb(0, 0, 0); line-height: 12px;" size="3">Low Prices on a Great Selection Free Delivery on orders over £15</font>

  • wow gold (unregistered)
    Comment held for moderation.

Leave a comment on “I Think I'll Put It ... Here”

Log In or post as a guest

Replying to comment #:

« Return to Article