Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!multikabel.net!newsfeed20.multikabel.net!post40.multikabel.net!cache60.multikabel.net!not-for-mail From: "Skybuck Flying" Newsgroups: alt.comp.lang.borland-delphi,comp.lang.c,comp.lang.java.programmer References: <29308868.1994.1337265697084.JavaMail.geo-discussion-forums@pbcuc6> <84131$4fb54067$5419acc3$20839@cache90.multikabel.net> In-Reply-To: Subject: Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Date: Thu, 17 May 2012 23:25:08 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 15.4.3538.513 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3538.513 Message-ID: <4e980$4fb56cac$5419acc3$13190@cache60.multikabel.net> X-Complaints-To: abuse@ziggo.nl Organization: Ziggo Lines: 85 NNTP-Posting-Host: 84.25.172.195 (84.25.172.195) NNTP-Posting-Date: Thu, 17 May 2012 23:25:00 +0200 X-Trace: 4e9804fb56cacf1bc096613190 Xref: csiph.com comp.lang.c:20937 comp.lang.java.programmer:14594 " "glen herrmannsfeldt" wrote in message news:jp3g9r$v22$1@speranza.aioe.org... In comp.lang.java.programmer Skybuck Flying wrote: (snip) >>> if (fromIndex < 0) >>> throw new ArrayIndexOutOfBoundsException(fromIndex); >>> if (toIndex > arrayLen) >>> throw new ArrayIndexOutOfBoundsException(toIndex); (snip, someone else wrote) >> I believe it is checking whether the range fromIndex, fromIndex+1, ..., >> toIndex-1 -- i.e., a range given as the first index and one past the >> last index, not an uncommon practice -- is within the array, in which >> case it has no bugs. (toIndex may legally equal the length of the array >> when the range extends to the last element, and requiring the range to >> be specified "the right way around" is not especially perverse.) >> " > It's simply not valid. Out of bounds has a very clear meaning > in programming practice. It's either within bounds or it's not. But this isn't "programming" it is Java, and Java can do it however it wants to. > The bounds of a java array are very clearly defined. Thus the > only logical conclusion is that the code is simply bugged. > Either in logic or in description. Either change the > exception-description or fix the code. Look at the definition of the substring method in String class. It avoids a lot of -1 by the programmer to define it this way. (Along with consistently starting indexing at zero.) " Not really, Programmers of all languages must be able to communicate with each other through common language and concepts. One such concept is "range". It's pretty clearly defined: http://en.wikipedia.org/wiki/Range_(computer_programming) Any computer language deviating from the standard/common meaning of range should clearly state so. Any code deviating from the standard/coming meaning of range should clearly state so. Obviously if the routine was ment to check "range" then it's flawed. Obviously if the routine was ment to check "range-1" then it’s name should have been slightly different to state just that, example: checkRangeMinusOne or checkRangeInclusiveExclusive or CheckRangeExceptLast Fortunately for us the code is available, but this is not always the case in other programming languages like C where sometimes only headers are available. Nice way to sneak in bugs ! ;) Bye, Skybuck.