Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.szaf.org!news.unit0.net!news.netfront.net!not-for-mail From: Wanja Gayk Newsgroups: comp.lang.java.programmer Subject: Re: Style Police (a rant) Date: Sat, 17 Sep 2011 00:57:04 +0200 Organization: Netfront http://www.netfront.net/ Lines: 35 Message-ID: References: NNTP-Posting-Host: 77.8.37.174 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1316213821 55948 77.8.37.174 (16 Sep 2011 22:57:01 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Fri, 16 Sep 2011 22:57:01 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8093 In article , avl@gamma.logic.tuwien.ac.at says... > While a *non*-final List typed variable could later be assigned > an instance of LinkedList, a final can't. It hardly ever hurts > to have a final variable carry the most specific subtype. Really? final x = new Vector(); Enumeration e = x.elements(); ... Now a few weeks later, after every bit in the program assumes it can use the methods specific to Vector, you decide it's better to use a LinkedList and just change the assignment: final x = new LinkedList(); Enumeration e = x.elements(); <<- and breaks this and everything else that relied on the specific type. Abstraction is the whole point of declaring interfaces, you don't want your code to be brittle. Kind regards, Wanja -- ..Alesi's problem was that the back of the car was jumping up and down dangerously - and I can assure you from having been teammate to Jean Alesi and knowing what kind of cars that he can pull up with, when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer] --- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---