1. 10

  2. 7

    Really, the code is only identical because the two limits happen to (currently) have the same value.

    I think just naming the limits would make it clear that the code is capturing two different restrictions? As well as going a long way to helping the code explain itself.

    1. 3

      Sort of unrelated…..

      A colleague of mine told me this lovely tale….

      He worked once with a brilliant Physicist.

      Lousy Software Engineer, but brilliant Physicist.

      Their boss asked the software guys to explain to this physicist how to write maintainable code…. so they started off gentle and explained the “No magic constants” rule, (which you are implicitly referring to above).

      When they next looked at his code, it had…

      #define FOUR 4

      …the last time he look at that code before he left it was….

      #define FOUR 5