It's not a secret anymore!
The moose likes Java in General and the fly likes Java Puzzlers: Traps, Pitfalls, and Corner Cases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Puzzlers: Traps, Pitfalls, and Corner Cases" Watch "Java Puzzlers: Traps, Pitfalls, and Corner Cases" New topic

Java Puzzlers: Traps, Pitfalls, and Corner Cases

Michael Davis

Joined: Sep 27, 2004
Posts: 3
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?


Michael A. Davis.
[ August 09, 2005: Message edited by: Michael Davis ]
simi shonowo

Joined: Apr 27, 2005
Posts: 2
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

Joined: Jan 30, 2000
Posts: 18671
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.

"I'm not back." - Bill Harding, Twister
Joshua Bloch
Author and "Sun God"
Ranch Hand

Joined: May 30, 2001
Posts: 124
Jim (as usual) got this exactly right.

Josh and Neal

Joshua Bloch <br />Author of <a href="" target="_blank" rel="nofollow">Effective Java</a> and coauthor of <a href="" target="_blank" rel="nofollow">Java Puzzlers</a>
I agree. Here's the link:
subject: Java Puzzlers: Traps, Pitfalls, and Corner Cases
It's not a secret anymore!