Groups | Search | Server Info | Keyboard shortcuts | Login | Register


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

Re: Passing a Method Name to a Method

From "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com>
Newsgroups comp.lang.java.programmer
Subject Re: Passing a Method Name to a Method
Date 2011-06-23 15:46 -0400
Organization IBM
Message-ID <iu0569$aek$1@speranza.aioe.org> (permalink)
References (1 earlier) <itu8gk$cej$1@dont-email.me> <R_FMp.28711$F25.8866@newsfe04.iad> <oop-20110623155958@ram.dialup.fu-berlin.de> <itvtu3$m04$2@speranza.aioe.org> <iu00rm$vel$1@dont-email.me>

Show all headers | View raw


On 23/06/2011 2:32 PM, markspace wrote:
> On 6/23/2011 10:42 AM, Fuschia, President-Elect of the Bright
>>
>> I'll just mention here that functional programming, in this case at
>> least, also gives the advantages given by object oriented programming;
>> specifically, you can add another parse method by adding another (third)
>> parse *function* without changing most of the other code. And generally
>
> I'll just mention here that this is fairly specious.

Wrong.

> A proper OO solution, like the ones I gave, you can add another parser
> just by adding the appropriate class. The boiler plate is about two lines.

1. package foo;
2.
3. import bar.baz.ParseStrategy;
4.
5. public final class MyParseStrategy implements ParseStrategy {
6.     public final Thingy parse (String input) {
7.         // The actual implementation goes here
8.     }
9. }

I count 8 lines of non-implementation code, not 2, and 162 characters, 
plus eight "extra" characters per line of implementation code to indent 
it properly. Versus this Clojure code:

(defn my-parse [input]
   (the actual implementation goes here))

ONE line of non-implementation code and 26 characters, plus two indent 
spaces per line of implementation code.

1/8 as many lines. 1/6 as many characters. 1/4 as many indent spaces per 
line of implementation code. And probably a shorter & sweeter 
implementation as well.

> The interface is already done, skeleton, imports, etc are already done.
> Just add a class with a method. What you gain in Java is type safety,
> something not available in the "functional" languages I'm familiar with.

Scala also gets you type safety, at a cost of a bit more boilerplate 
than the Clojure example.

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


Thread

Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-22 12:46 -0700
  Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-22 16:00 -0400
    Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 14:40 -0700
      Re: isIdentifierCharacter (was: Passing a Method Name to a Method) Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:09 -0700
  Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-22 14:14 -0700
    Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-22 22:59 -0400
    Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-23 17:49 +0000
      Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-23 11:22 -0700
        Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-24 19:15 +0000
  Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-22 22:09 -0400
    Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 09:07 -0700
      Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 13:43 -0400
        Re: Passing a Method Name to a Method Nebulous <nebulous99@gmail.com> - 2011-06-23 13:57 -0700
      Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-24 07:28 -0400
    Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-23 17:53 +0000
  Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-22 22:30 -0400
    Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 09:06 -0300
      Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 13:23 -0300
        Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 09:33 -0700
          Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 17:53 -0300
            Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 19:15 -0700
              Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-24 01:48 -0400
                Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-24 02:20 -0400
                Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-25 15:26 -0400
      Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 13:42 -0400
        Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-23 11:32 -0700
          Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 16:23 -0300
          Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 15:46 -0400
      Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:29 -0700
    Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 14:44 -0700
      Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-24 07:48 -0400
  Re: Passing a Method Name to a Method Roedy Green <see_website@mindprod.com.invalid> - 2011-06-23 09:43 -0700

csiph-web