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:
- Sanity check
- Input check
- Boundary case? Edge case? Corner case?
- Base case? Boundary case?
- Corner case? Edge case?