Hello Richard, I use to write my code that way, that it tells as much as possible to the reader.
If I write List list = new ArrayList(); it tells, that it needs only an instance of a List (== sorted Collection). If I write ArrayList list = new ArrayList(); it tells, that it needs an ArrayList, because of some special functionality. If I write Collection coll = new ArrayList(); it tells, that it only needs a storage to put some objects in, nothing more, not less. But Alains request was more general: to allow to specify any (super)-class or implemented interface as the variable type. And this is indeed a very useful thing. Tom At 06:32 21.02.02 -0600, you wrote: >What are your reasons, Alain? >(I see, two reasons but I wouldn't put either of them as a general rule.) >If you want to use the variable just locally, why not allow to use the whole >ArrayList functionality? >If you want to pass it in an List argument, you just pass it as ArrayList. > >I found it being much better coding habit to have the variable of the same >type as the value (if possible). And I'm sure there are more "theory-founded" >reasonings for that. > >r. >-----Original Message----- >From: Alain Ravet [mailto:[EMAIL PROTECTED]] >Sent: Thursday, February 21, 2002 5:48 AM >To: [EMAIL PROTECTED] >Subject: [Eap-features] introduce variable : encourage use of interface > >When using "Introduce Variable" on > . > new ArrayList (); > >you get > > ArrayList arrayList = new ArrayList (); > > >Most of the time, though, you should use > . > List arrayList = new ArrayList (); > > > >"Introduce Variable" should allow the user to choose it's target type. > > >Alain Ravet _______________________________________________ Eap-features mailing list [EMAIL PROTECTED] http://www.intellij.com/mailman/listinfo/eap-features
