Terminology – Differences Between Edge Case, Corner Case, Base Case, and Boundary Case

terminology

I'm not a native English speaker. In my native language I'm aware of some terms used to refer to the condition checked to stop a recursion, and to the condition checked for extreme, unlikely or super-simple cases. In English, I've encountered the terms "edge case", "corner case", "boundary case" and "base case", but I can't quite figure out the differences and which is used to refer to what; I'd love to get some summary of the differences between them.

In particular, I would be very happy if someone could provide annotations for the lines in the following code sample:

    int transmogrify(int n) {
1.      assert(n <= 1000000);
2.      if (n < 0) return -1;
3.      if (n == 1000000) return PRE_CALC;
4.      if (n == 0) return n+1;            // For stopping the recursion
5.      if (n == 1251) return 3077;
        return transmogrify(n-1);
    }

I think it's:

  1. Sanity check
  2. Input check
  3. Boundary case? Edge case? Corner case?
  4. Base case? Boundary case?
  5. Corner case? Edge case?

Best Answer

I'm not a native English speaker either. But according to Wikipedia:

  • Edge case occurs at an extreme (maximum or minimum) operating parameter.
  • Corner case occurs outside of normal operating parameters, specifically when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range for that parameter. (The "outside normal operating parameters" obviously means something like "outside typical combination of operating parameters", not strictly "outside allowed operating parameters". That is, you're still within the valid parameter space, but near its corner.)
  • Boundary case occurs when one of inputs is at or just beyond maximum or minimum limits.
  • Base case is where Recursion ends.

So, the nomenclature seems to be totally confused, even though corner case seems to mean something a bit different (a combination of values) than edge and boundary cases, which are definitely synonymes. It's probably safe to say that edge, corner, and boundary cases are the same thing in common speech. Someone could mean to say different thing by each of them, but there's hardly any common agreement.

Your 1) and 2) are what you wrote, 3) is a edge/boundary case, 4) is a base case, and 5) is a special case.