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


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

Re: Holy boop: goto for Java

From Gene Wirchenko <genew@ocis.net>
Newsgroups comp.lang.java.programmer
Subject Re: Holy boop: goto for Java
Date 2012-06-04 14:46 -0700
Organization A noiseless patient Spider
Message-ID <fcaqs7tmd7776rg5gtem1lmqnabq6bnala@4ax.com> (permalink)
References (3 earlier) <jqhcth$u5a$1@news.albasani.net> <hsZyr.46128$Gm4.1924@newsfe01.iad> <77a353f2-0933-413a-8e47-df577ba64976@googlegroups.com> <Qz8zr.20556$FL5.14442@newsfe03.iad> <mJ8zr.2386$AK.1031@newsfe07.iad>

Show all headers | View raw


On Mon, 04 Jun 2012 13:17:21 -0700, Daniel Pitts
<newsgroup.nospam@virtualinfinity.net> wrote:

>On 6/4/12 1:07 PM, Arved Sandstrom wrote:
>> On 12-06-04 04:37 AM, Robert Klemme wrote:
>>> On Monday, June 4, 2012 9:28:13 AM UTC+2, Arved Sandstrom wrote:
>>>> What amazes me is that these individuals support this religious stance
>>>> by arguing that it improves readability, when producing little auxiliary
>>>> methods usually does anything but.

     Personally, I find this sort of stuff to be very unreadable.  If
it is used multiple times, it is not quite so bad.  If it is used but
once, it is a disruption to following the caller.

>>> I am not religious about break / continue (although I use it extremely
>>> seldom, I am more likely to use "return" inside a loop). But I
>>> disagree about your general statement about little auxiliary methods
>>> usually not improving readability. It all depends on the specific
>>> case, of course, but giving a short part of an algorithm a name (with
>>> the option to have a place to put JavaDoc) often helps readability in
>>> my experience.

>> When I mean "little", I mean little - like 2 or 3 lines little. Based on
>> the "no exceptions NEVER use labeled break/continue" language that I've
>> seen in threads on this subject, and the invariable suggestion of using
>> extracted helper methods instead, this *inevitably* means that many of
>> these helper methods will be that small. After all, the body of such a
>> method would be whatever the body of the inner loop is, and in my
>> experience that's often small.

     There is also context to consider.  I have sometimes considered
moving some short, common code to subroutines to find that by the time
I re-established the context in the subroutine, the subroutine's code
would be longer than having the code in the caller.

>> I am not super-dogmatic about many things, but one thing I will not
>> yield ground on is the readability hit of little (1-3 lines of Java)
>> methods. *Sometimes*, with a well-chosen name, and general
>> applicability, these are perfectly OK. But these idiots in these threads
>> I allude to are talking about extracting all code in an inner loop, if
>> it would require a conditional break or continue, robotically making a
>> method out of it

     That is extreme.

>No need to call me an idiot. Actually, I don't advocate "extracting all 
>code in an inner loop, if it would require a conditional break or 
>continue".  I advocate distinct intuitive steps into simple methods, 
>always, unless you have a specific reason not to.  A good reason, not 
>just any reason.

     You are talking past each other.  He is not talking about
intuitive steps, but just automatic "methodising" of code.

>Many experts in the field of software design agree. I learned this 
>practice directly from Martin Fowler as a matter of fact, in a training 
>session he did on TDD at my company.
>
>> - even if that outer loop is the only caller -
>Who calls a method is irrelevant to only value of such a method, unless 
>the number of callers is zero of course.

     If it is only one, in-line might be better.

>> without any intelligent thought whatsoever.
>Intelligent thought is always required, for all software design. The 
>problem is when people do things by guessing.

     Or by manifesto which is much the same.

>> Can you imagine what kind of names such methods might have? How about
>> "innerLoopStuff()"?
>It depends on the loop. How about instead "processNextStuff()" (where 
>stuff is replaced with a meaningful name).

     innerLoopStuff2(), innerLoopStuff3(), ... ?

>I'm not going to say "It must always be done!" but I will say that when 
>done *right*, it will improve the maintainability of the code base 
>significantly.

     But then it probably would be done as the code is written,
because it is a sensible -- what you called "intuitive" above --
design.

     I like my code to tell a story at one level of abstraction.  It
makes it easier to follow the logic.  The high-level code is all in
one sequence.  With this, I can skip the lower-level logic most of the
time.  If I need to adjust the higher-level logic, it is a good sign
when I do not have to concern myself much with the lower-level logic
(because what I came up with for it is still what is needed).

>Thanks,
>Daniel
>Yet Another Idiot Apparently.

     Nope.  You are too thoughtful for that.

Sincerely,

Gene Wirchenko

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


Thread

Holy boop: goto for Java markspace <-@.> - 2012-06-03 19:36 -0700
  Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-03 20:03 -0700
    Re: Holy boop: goto for Java markspace <-@.> - 2012-06-03 20:30 -0700
      Re: Holy boop: goto for Java Lew <noone@lewscanon.com> - 2012-06-03 21:17 -0700
        Re: Holy boop: goto for Java Robert Klemme <shortcutter@googlemail.com> - 2012-06-04 07:56 +0200
        Re: Holy boop: goto for Java Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-06-04 04:28 -0300
          Re: Holy boop: goto for Java Robert Klemme <shortcutter@googlemail.com> - 2012-06-04 00:37 -0700
            Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-04 07:43 -0700
              Re: Holy boop: goto for Java "Mike Schilling" <mscottschilling@hotmail.com> - 2012-06-04 07:47 -0700
                Re: Holy boop: goto for Java "Mike Schilling" <mscottschilling@hotmail.com> - 2012-06-04 08:17 -0700
            Re: Holy boop: goto for Java Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-06-04 17:07 -0300
              Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-04 13:17 -0700
                Re: Holy boop: goto for Java Gene Wirchenko <genew@ocis.net> - 2012-06-04 14:46 -0700
                Re: Holy boop: goto for Java Robert Klemme <shortcutter@googlemail.com> - 2012-06-05 07:31 +0200
                Re: Holy boop: goto for Java Gene Wirchenko <genew@ocis.net> - 2012-06-05 09:15 -0700
                Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-05 10:51 -0700
                Re: Holy boop: goto for Java Gene Wirchenko <genew@ocis.net> - 2012-06-05 10:54 -0700
                Re: Holy boop: goto for Java Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-06-06 05:58 -0300
                Re: Holy boop: goto for Java Lew <lewbloch@gmail.com> - 2012-06-06 12:11 -0700
                Re: Holy boop: goto for Java Robert Klemme <shortcutter@googlemail.com> - 2012-06-05 23:24 +0200
                Re: Holy boop: goto for Java Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-05 17:30 -0400
                Re: Holy boop: goto for Java Gene Wirchenko <genew@ocis.net> - 2012-06-05 20:06 -0700
            Re: Holy boop: goto for Java Patricia Shanahan <pats@acm.org> - 2012-07-22 06:37 -0700
              Re: Holy boop: goto for Java Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-07-23 13:27 -0500
                Re: Holy boop: goto for Java Gene Wirchenko <genew@ocis.net> - 2012-07-23 13:23 -0700
          Re: Holy boop: goto for Java Lew <lewbloch@gmail.com> - 2012-06-04 09:33 -0700
        Re: Holy boop: goto for Java Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-04 07:26 -0400
        Re: Holy boop: goto for Java "Mike Schilling" <mscottschilling@hotmail.com> - 2012-06-04 07:44 -0700
          Re: Holy boop: goto for Java Robert Klemme <shortcutter@googlemail.com> - 2012-06-04 18:13 +0200
            Re: Holy boop: goto for Java Gene Wirchenko <genew@ocis.net> - 2012-06-04 10:23 -0700
              Re: Holy boop: goto for Java Lew <lewbloch@gmail.com> - 2012-06-04 10:45 -0700
                Re: Holy boop: goto for Java Robert Klemme <shortcutter@googlemail.com> - 2012-06-04 20:31 +0200
                Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-04 11:52 -0700
                Re: Holy boop: goto for Java Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-04 14:15 -0500
                Re: Holy boop: goto for Java Lew <lewbloch@gmail.com> - 2012-06-04 14:52 -0700
          Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-04 10:50 -0700
          Re: Holy boop: goto for Java Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-04 10:56 -0700
          Re: Holy boop: goto for Java Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-04 13:05 -0500
    Re: Holy boop: goto for Java Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-04 07:28 -0400
  Re: Holy boop: goto for Java Roedy Green <see_website@mindprod.com.invalid> - 2012-06-03 22:10 -0700

csiph-web