|
Authored by: Anonymous on Thursday, April 19 2012 @ 03:37 PM EDT |
checkStartAndEnd is not functionally equivalent. It prioritizes the opposite
way - out-of-bounds is higher-priority than bad arguments. And it throws the
same exception for both out-of-bounds conditions.
On the other hand, this
is an internal sanity check. It is not validating user input, it is validating
that a programmer has not done something stupid. Therefore in properly
functioning code it will never throw any exception. It should only ever be
activated during debugging of new code. [ Reply to This | Parent | # ]
|
|
Authored by: tknarr on Thursday, April 19 2012 @ 05:28 PM EDT |
AAMAF, IAASD. As a professional programmer, I'd look at the
rangeCheck() functions as written and say there's nothing creative there. The
functions are required to do 3 checks, and they do them in the obvious order.
Any programmer handed this spec is going to do checks in the order they're
specified. The code for each check is the minimum allowed by the language to do
the check, there's no real alternative way to do the checks without being
deliberately stupid about it. The formatting... is the standard formatting for
Sun's Java code style, in fact if I fire up Eclipse and do a "reformat file" on
that code it's going to end up laid out exactly as it is in these examples. Long
and short, the code here's what any programmer given this problem would produce
and it's the only reasonable way to do this particular job without introducing
deliberate inefficiency and/or stupidity into the code. Trying to copyright this
code would be like trying to copyright the standard "gun barrel poking through
the gap in a slightly opened door" trope from murder/suspense movies. [ Reply to This | Parent | # ]
|
|
|
|
|