Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #3227

Re: Initializing from context passing

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: Initializing from context passing
Date 2011-04-23 20:32 -0400
Organization albasani.net
Message-ID <iovr28$4la$1@news.albasani.net> (permalink)
References <91ga4tF38vU1@mid.individual.net> <iouv3r$5ls$1@dont-email.me> <91gnv8F6ooU1@mid.individual.net> <iovk75$jdp$3@news.albasani.net> <91h8hcFlmbU1@mid.individual.net>

Show all headers | View raw


Dirk Bruere at NeoPax wrote:
> But having said that, all the examples I have seen use ArrayList and not List

I will assume you mean for the declared type of the variable and not the 
runtime instantiated type, since the latter cannot be 'List' as such.

The question is why they do.  Several possibilities exist, including but not 
limited to:

- The API with which they interact is so poorly designed as to specify 
'ArrayList' arguments or return types.

- You are going to really, really poor sources for examples.

- The pedagogical purpose of the examples has nothing to do whatsoever with 
the best practice of declaring the wider type, therefore they disregarded it.

Regardless, only the first reason is compelling, and in the case of 
'android.widget.ArrayAdapter<T>', inapplicable.

Just because the examples you saw used 'ArrayList' as declared variable types, 
the fact that the API library only requires 'List' should have tipped you off. 
  Programming is an art that requires thinking.  The other red flag is that 
the declaration of 'ArrayList' variables is a violation of a best practice, 
and should send one scurrying about looking for why it was done, not 
unquestioningly following cattle to the slaughterhouse.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-23 16:39 +0100
  Re: Initializing from context passing Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-23 18:35 +0200
    Re: Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-23 19:12 +0100
      Re: Initializing from context passing Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-23 21:47 +0200
    Re: Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-23 20:34 +0100
      Re: Initializing from context passing Lew <noone@lewscanon.com> - 2011-04-23 18:35 -0400
        Re: Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-24 01:17 +0100
          Re: Initializing from context passing Lew <noone@lewscanon.com> - 2011-04-23 20:32 -0400

csiph-web