> dlr         01/07/24 22:39:03

Hi Daniel!

>   Modified:    src/java/org/apache/turbine Turbine.java
>   Log:
>   Removed early return (having only one exit point from a method is
>   preferable).

[This is a minor point, and I don't mean to start a religious war;
 if anybody feels like ignoring this, just go ahead... 8-)
 Even more, the example I provide may not apply for this particular
 change in cvs.]

I beg to disagree. I find it very hard to read code structured like this:

  ret = null;
  preA();
  if (A)
  {
    preB();
    if (B)
    {
      preC();
      if (C)
      {
        ret = do();
      }
      else
      {
        ret = notC();
      }
    }
    else
    {
      ret = notB();
    }
  }
  else
  {
    ret = notA();
  }
  return ret;

and find this is a lot more readable:

  preA();
  if (! A)
  {
    return notA();
  }

  preB();
  if (! B)
  {
    return notB();
  }

  preC();
  if (! C)
  {
    return notC();
  }

  return do(); 

In my opinion, it is clearer and more maintainable; at least, it
is easier to add a new case for D...

Regards,


-- 
Gonzalo A. Diethelm
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to