| « Prev | Page 1 | Next » |
|
Worst kind of OO is the clueless OO.
|
|
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. |
|
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 |
|
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?
|
|
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. |
|
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. |
|
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... :)) |
|
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
|
Re: I Think I'll Put It ... Here
2005-03-10 17:44
•
by
codeman38
|
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. :) |
|
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");
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. The best way to fix that would be to insert the following code before int j is declared: for (final Iterator i = atmTrafficDescrsList.iterator(); i.hasNext();) 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. |
Re: I Think I'll Put It ... Here
2005-03-10 18:18
•
by
Jeremy Morton
|
Agreed, but I wanted to point out that you missed incrementing j in your code. |
Dammit! So I did. |
|
Hm. Cool. So let's see how you'd do it in Ruby.
cbr_descrs = DataStore::get_object_list("ATMTrafficDescr").select { |d| d.enabled? && d.service_class == "CBR" } data = cbr_descrs.collect { |d| [ d.name, d.pcr ] } |
|
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. [:)] |
|
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")
|
|
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. |
|
I get 2 google ads for G-Strings at the top of my page [:D]
|
Re: I Think I'll Put It ... Here
2005-03-11 05:40
•
by
nickelarse
|
|
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. |
|
hey i don get google ads, not that im complaining!! |
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. |
|
Seems like we're dealing another kind of Strings for Google:
Guitar strings Low Prices on a Great Selection Free Delivery on orders over £15 |
|
Out of runes of magic gold? Need it in urgent? Yes, I can understand you. As the most important currency, without rom gold, you ever can’t do anything. So you need to buy rom gold from those most professional and loyal game online shops with years’ experience and have a good reputation among players. Is there any difficult? No, when you need the rom gold, please feel free to contact us, we are promising to offer you the cheap runes of magic gold with fastest delivery. Moreover, we are online 24/7, you can contact us any time with any question about. So why are you still irresolute? Come here to grab your cheap runes of magic gold now. Crazy about running warhammer gold? Yup, it is so crucial indeed for us in Warhammer Online. Without it, we can even do nothing, without money to buy items, weapons and so on. So enough warhammer gold is substantial.
|
| « Prev | Page 1 | Next » |