Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror

Comment Re:Keep it simple! (Score 1) 956

(Ayee, my regrets: my former reply was added as HTML where it should have been plain-old text.)

I consider goto (like some before me) obsolete and its use obnoxious.

This function screams for a simple for-loop. I know it is possible to use fewer local variables and a little less arithmetic. Probably there is also a more elegant recursive solution, however tending to be less readable and more error-prone. Coding-quality should prevail above beauty and elegance?

SOLUTION EXAMPLE

int multiply( int a, int b)
{
      int x=0; // define local variable
      int y=1; // define local variable
      if (!( a > 0 )) return -1; // short noted version of for-loop (i.e.: for (expression) {statement} ) is against aforementioned JSF coding principles // long noted version of for-loop with whitespace follows below

      for (y=1; y=a, y++)
      {
            x+=b
      }

      return x;
}

Slashdot Top Deals

You have mail.

Working...