Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.glorb.com!news.netfront.net!not-for-mail From: Wanja Gayk Newsgroups: comp.lang.java.programmer Subject: Re: Abstract Class versus an Interface, when no Members in Common Date: Tue, 8 Nov 2011 23:15:33 +0100 Organization: Netfront http://www.netfront.net/ Lines: 31 Message-ID: References: <22857359-211e-443e-9c5d-6cc2f5bd971b@m19g2000vbm.googlegroups.com> <3iYsq.9363$zi2.7579@newsfe10.iad> NNTP-Posting-Host: 77.8.33.249 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1320790530 362 77.8.33.249 (8 Nov 2011 22:15:30 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Tue, 8 Nov 2011 22:15:30 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9789 In article <3iYsq.9363$zi2.7579@newsfe10.iad>, newsgroup.nospam@virtualinfinity.net says... > Sounds almost like you want a visitor pattern instead, or an > intermediate object: > > public class SearchResult { > public boolean isSingleArray() { ... } > public boolean isMultipleArray() { ... } > > // Throws IllegalStateException if !isSingleArray > public SingleArray getSingleArray() { ... } > // Throws IllegalStateException if !isMutipleArray > public MultipleArray getMultipleArray() { ... } > > } That doesn't seem to be any better than the infamous instaceof-cascade - I'd rather say it's even uglier. 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 ---