f



Abandon java.util.Hashtable and java.util.Vector

Abandon java.util.Hashtable and java.util.Vector. Use other java.util.Map and 
java.util.List implementations instead, such as java.util.HashMap and 
java.util.ArrayList, respectively.

While you're at it, don't use java.util.Enumeration; stick with 
java.util.Iterator.

-- Lew
0
Lew
3/31/2007 6:24:56 PM
comp.lang.java.advocacy 1727 articles. 0 followers. see_website (5876) is leader. Post Follow

5 Replies
387 Views

Similar Articles

[PageSpeed] 33

On Mar 31, 8:24 pm, Lew <l...@nospam.lewscanon.com> wrote:
> Abandon java.util.Hashtable and java.util.Vector. Use other java.util.Map and
> java.util.List implementations instead, such as java.util.HashMap and
> java.util.ArrayList, respectively.

Tell that the m*th*f*ck*s at Sun who still haven't updated many
standard APIs to use the "new" collection interfaces and classes.

0
a24900
4/1/2007 7:27:21 AM
In comp.lang.java.advocacy, Lew
<lew@nospam.lewscanon.com>
 wrote
on Sat, 31 Mar 2007 14:24:56 -0400
<koydnUqbGvfkOpPbnZ2dnUVZ_h3inZ2d@comcast.com>:
> Abandon java.util.Hashtable and java.util.Vector. Use other java.util.Map and 
> java.util.List implementations instead, such as java.util.HashMap and 
> java.util.ArrayList, respectively.
>
> While you're at it, don't use java.util.Enumeration; stick with 
> java.util.Iterator.
>
> -- Lew

And of course the proper method by which one should use these is

List<T> v = new ArrayList<T>();

to abstract the problem, whenever possible.

Of course it might be even better if we had a new interface
RandomAccessList (extends List, requires get(int) --
one of my pet peeves), but that might get a tad unwieldly.

-- 
#191, ewill3@earthlink.net
"640K ought to be enough for anybody."
  - allegedly said by Bill Gates, 1981, but somebody had to make this up!

-- 
Posted via a free Usenet account from http://www.teranews.com

0
The
4/2/2007 1:30:52 PM
On Mar 31, 2:24 pm, Lew <l...@nospam.lewscanon.com> wrote:
> Abandon java.util.Hashtable and java.util.Vector. Use other java.util.Map and
> java.util.List implementations instead, such as java.util.HashMap and
> java.util.ArrayList, respectively.
>
> While you're at it, don't use java.util.Enumeration; stick with
> java.util.Iterator.
>
> -- Lew


Sorry, but I'm so used to it (I'm an old timer from the mid-1990s)
that I just can't stop myself...you should see my MIDP apps...just
littered with vectors they are ;-)



0
asjbiotek
4/4/2007 1:05:39 PM
Lew <l...@nospam.lewscanon.com> wrote:
>> Abandon java.util.Hashtable and java.util.Vector. Use other java.util.Map and
>> java.util.List implementations instead, such as java.util.HashMap and
>> java.util.ArrayList, respectively.
>>
>> While you're at it, don't use java.util.Enumeration; stick with
>> java.util.Iterator.

asjbiotek@gmail.com wrote:
> Sorry, but I'm so used to it (I'm an old timer from the mid-1990s)
> that I just can't stop myself...you should see my MIDP apps...just
> littered with vectors they are ;-)

I should have said J2ME excepted.  Good catch.

To be fair, there are times when those retiree classes are useful, although I 
do prefer the nimbler Collections.synchronizedX() where appropriate.  But a 
wimpy "eschew" exhortation would be less inspiring than the demagogic 
"abandon", eh?

My problem is not with Java 1.0 veterans, old-timer.  I respect the service 
you provided our community and honor your sacrifice.  (I've been programming 
Java professionally since 1999 myself; first starting learning it in about 
'97.  Used to have to make our bits by hand out of wood back then, ayep.)

My problem is with those whippersnappers who come fresh out of Struts 101 and 
write Web apps with these hoary legacy classes.  Who's teaching them this 
stuff, at least who's doing so without explaining the appropriate contexts and 
the differences from the next-gen Collections classes that have been around 
for almost nine years now (~ 3/4 the public life and virtually all the popular 
life of Java itself)?

Even Rip-van-Winkle Java programmers should know that the synchronization 
overhead of Vector and Hashtable is unnecessary when ArrayList and HashMap are 
available and the use is thread local.

-- 
Lew
0
Lew
4/4/2007 1:27:26 PM
On Apr 4, 9:27 am, Lew <l...@nospam.lewscanon.com> wrote:
> My problem is not with Java 1.0 veterans, old-timer.  I respect the service
> you provided our community and honor your sacrifice.  (I've been programming
> Java professionally since 1999 myself; first starting learning it in about
> '97.  Used to have to make our bits by hand out of wood back then, ayep.)
>
> --
> Lew

1. No sacrifices, I've absolutely loved my time doing java. Am into
Java ME nowadays, but I used to jump all over the place, from smart
cards to Lego stuff even....

2. I beat you by only 2 years....started professionally 1997 doing
applets* ;-)

* which incredibly enough, even after years of abuse is still with us
today and thriving!






0
asjbiotek
4/8/2007 1:42:11 AM
Reply: