Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • In one of his talks (Enterprise Perl?) James Duncan discussed readable code and gives the excellent advice that every loop should be a method. I find myself doing this more with Java than Perl, probably because I hit the mental ceiling for method length with Java's verbosity. So I'd typically translate your example to a method like:


    One side-effect of Java's not having unless is that I tend to write both 'isSomething' and 'isNotSomething' for readability, especially because an '!' always gets lost:

    if ( ! foo.isSomething() ) { ... }
    if ( foo.isNotSomething() ) { ... }

    The first example is particularly difficult to read when developers don't use sufficient whitespace, like:

    if (! foo.isSomething() ) { ... }

    or even the painful:

    if (!foo.isSomething()) { ... }

    I'm always surprised that I rarely see discussions of whitespace in code readability. Do people consider this a religious issue like where to put braces?

    • I think that might be the case sometimes. I also think that there are people that just don't care. I've asked someone at work why they wrote this:


      my $x = $test > 5 ? 'foo' : 'bar';

      And they literally didn't see the difference. It's quite depressing.