Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Initializing from context passing Date: Sat, 23 Apr 2011 20:32:16 -0400 Organization: albasani.net Lines: 31 Message-ID: References: <91ga4tF38vU1@mid.individual.net> <91gnv8F6ooU1@mid.individual.net> <91h8hcFlmbU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net Ol7Ayo/kJoPj0H6YVmvQb2itsUo7SQAXg7Hn6wDRMYxsbnoIzJdKa8jnjGfIx9VUkSztEicT3FqrZuT2C/I2Eg== NNTP-Posting-Date: Sun, 24 Apr 2011 00:32:08 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="Ns0JTatjmZwoNSqT2UCU7KhAvcTAGH6G1KJ4WTVbWWDzGEtqo5Y8Mg6LQTaOSVxdwKnZjIlU2LHl7vTZkkZQyeebTcSQh6x5JKtLPUclESeOZrRubcFg5aqiqNCqd33G"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: <91h8hcFlmbU1@mid.individual.net> Cancel-Lock: sha1:S1C8L2Rq8LDovLhkwUl+P/vzFBs= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3227 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', 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