- 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
Worst kind of OO is the clueless OO.
Admin
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.
Admin
<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>
Admin
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?
Admin
<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>
Admin
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.
Admin
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... :))
Admin
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>
Admin
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. :)
Admin
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).
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>
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.
Admin
Agreed, but I wanted to point out that you missed incrementing j in your code.
Admin
Dammit! So I did.
Admin
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>
Admin
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. [:)]
Admin
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:
Admin
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.
Admin
I get 2 google ads for G-Strings at the top of my page [:D]
Admin
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.
Admin
hey i don get google ads, not that im complaining!!
Admin
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.
Admin
<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>