Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


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

Re: Passing a Method Name to a Method

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Passing a Method Name to a Method
References <81h4075t4gfjglji1n033rb20025ebho68@4ax.com> <itu8gk$cej$1@dont-email.me> <R_FMp.28711$F25.8866@newsfe04.iad> <oop-20110623155958@ram.dialup.fu-berlin.de>
Message-ID <fMJMp.17712$lW4.9107@newsfe07.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-06-23 13:23 -0300

Show all headers | View raw


On 11-06-23 11:01 AM, Stefan Ram wrote:
> Arved Sandstrom <asandstrom3minus1@eastlink.ca> writes:
>> At this stage of the game, considering the original problem statement, I
>> haven't seen any compelling arguments for not doing
>> for (i=1; i<=nRepetitions; i++)
>>    ParseThisWay(args);
>> and
>> for (i=1; i<=nRepetitions; i++)
>>    ParseThatWay(args);
> 
>   This is procedural programming, while the approach with the
>   same method name in different classes is object-oriented
>   programming, because it would use polymorphism.
> 
>   Under specific and fixed requirements, it is possible that
>   both solutions are equally well. However, requirements often
>   change in time.
> 
>   In the general case, object-oriented programing is better,
>   because it allows to add another parse method by adding
>   another (third) parse class /without changing/ most of the
>   other code and thus fulfills the open-closed principle,
>   while procedural programming usually would required code
>   changes in more places when adding a third way to parse.
> 
You're absolutely correct in almost all respects. I'd go further and
assert that in an adhoc, experimental situation then the procedural-type
solution (which is nothing to hold your nose for; a great deal of Java
code _is_ inevitably procedural, and later-generation hybrid- or
multi-paradigm languages acknowledge this reality) might even be better
because the hard-wiring looks adhoc and experimental and
throwaway...precisely because it _is_.

Setting things up the "OO way" in this situation, while aesthetically
appealing, also means that you've made a deliberate design decision to
allow for more straightforward swapping of parse logic. This _should_ be
a deliberate design choice. I'm sure you've read the odd article that
decries elaboration of implementation on a "what if?" and "just in case"
basis - I'm mostly in that camp.

This may seem like a trivial example - no harm done, and all that - but
over-engineering starts exactly with thought processes like this. And
the second you start designing and coding stuff to be more adaptable and
general-purpose, the more danger there is that the code is going to be
kept, and go into production. Not so desirable if the requirement didn't
exist. I know requirements often change, but my philosophy on that is,
provided that your project costing structure accurately assigns change
request costs to the people changing the requirements, make the cost of
requirements changes public, highly visible, and somewhat painful.

To return to my original point, with the added context of your reply
above, my argument remains this: we don't know what case this is.

AHS

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