Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Fuschia, President-Elect of the Bright Purplish-Green Council" Newsgroups: comp.lang.java.programmer Subject: Re: Passing a Method Name to a Method Date: Wed, 22 Jun 2011 22:59:54 -0400 Organization: IBM Lines: 27 Message-ID: References: <81h4075t4gfjglji1n033rb20025ebho68@4ax.com> NNTP-Posting-Host: uMh8BonO98FrRs3eYSTHIA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Xnews/2006.08.24 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5566 On 22/06/2011 5:14 PM, markspace wrote: > public interface Language { > parse( Reader in ); > } > > You could of course pass in the language at the same time, but that's a > little less OOD. > > public class Parser { > public static parse( Language parser, Reader in ) { > parser.parse( in ); > } > } > > Note that the "don't do it in Java" guy, Fuschia, is off his rocker. Wrong. > This is very efficient in Java as the JVM will recognize the JavaParser > class is effectively final and optimize the call to use non-virtual calls. I never claimed otherwise. In fact that approach is exactly what I recommended he use if he insisted on not going to a JVM language that better supports functional programming. It was using the Reflection API and Method objects that I said would not be efficient.