Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Puzzlers: Traps, Pitfalls, and Corner Cases

 
Michael Davis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about the title. What is a corner case, in the context of the book?

On Google, define: corner case gives:
A corner case is a problem or situation that occurs only outside of normal operating parameters--especially one that manifests itself when multiple environmental variables or conditions are simultaneously at extreme levels.

Is this the case for this book?

Thanks!

Michael A. Davis.
[ August 09, 2005: Message edited by: Michael Davis ]
 
simi shonowo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would be interested to know if the definition set up here is right. Corner cases seems like a very odd word to use for the description.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael, I guess you probably got that definition from Wikipdeia here? I think it's a pretty good definition, and probably matches what Josh & Neal are thinking of. (Though they may well say something else...)

S: I believe the term "corner case" probably comes from engineers who were thinking in terms of graphs. As in the example given on the Wikipedia definition: let's say we're designing a speaker system, and we wish to measure the distortion under various conditions. Let's say the system has just three controls: a volume control v, a bass control b, and a treble control t. That gives us three variables to consider, each of which has a range:

0 <= v <= V_MAX
0 <= b <= B_MAX
0 <= t <= T_MAX

We could make a 3D graph of these constraints, which would look like a box. If we wish to measure the distortion d of the system, and this is a finction of v, b, and t, then chances are good that some ofthe most interesting places to measure will be at or near the corners of the cube. E.g. how well does the system perform when all three controls are at their maximum? What if all three are at (or near) 0? What if one control is at 0 while the other two are at maximum? What if two are at 0 while one is at maximum?

Note that this is similar to an edge case. There's a bit of amgiguity here - if we have just two surfaces intersecting, are we looking at an edge or a corner? It depends on how you look at the graph. However ignoring that potential source of confusion, an edge case is generally when you consider only one variable, and a corner case is when you're considering more than one.

In computer science, the above definition may be taken very literally (e.g. if you're writing a math function which takes one or more input values and calculates an output) or it may be taken in a more vague and generalized way. Corner cases are special cases where some of the inputs have special values which cause unusual behavior. Exactly what this means will vary from method to method - and many methods may have no interesting corner cases.

For the title of Josh & Neal's book, perhaps it might have been more "correct" by this definition to say edge cases and corner cases. But that would've lengthed the title for little good reason. Essentially, edge cases are a simple subset of corner cases.
 
Joshua Bloch
Author and "Sun God"
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim (as usual) got this exactly right.

Josh and Neal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic