Hello, I want to outline two slightly different -1 cases but I am also willing to drop the constant.
(1) -1 is returned by the JRE String APIs and the JRE makes no constant available. The fact that no JRE constant is available is a shortcoming of the JRE, IMO. When Stephen writes "Personally I wouldn't use INDEX_NOT_FOUND, as -1 is so well known.", I tend to agree, since I /guess/ we are all used to reading test conditions like "if (string.api() != -1) ...". In this case INDEX_NOT_FOUND addresses a shortcoming in the JRE (I claim). (2) The second case is for our StringUtils APIs where /we/ "return -1", clearly a magic number, where I think we would be better served with "return INDEX_NOT_FOUND". So after distinguishing between these two cases, is INDEX_NOT_FOUND still uncomfortable in all cases? Thanks, Gary > -----Original Message----- > From: Steven Caswell [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 04, 2003 17:33 > To: 'Jakarta Commons Developers List' > Subject: RE: [lang] StringUtils.ordinalIndexOf() and INDEX_NOT_FOUND > > Unless you want to be as nerdy as I am and do it so that checkstyle > doesn't > complain. > > > Steven Caswell > [EMAIL PROTECTED] > a.k.a Mungo Knotwise of Michel Delving > "One ring to rule them all, one ring to find them..." > > > > -----Original Message----- > > From: Stephen Colebourne [mailto:[EMAIL PROTECTED] > > Sent: Thursday, September 04, 2003 6:22 PM > > To: Jakarta Commons Developers List > > Subject: Re: [lang] StringUtils.ordinalIndexOf() and INDEX_NOT_FOUND > > > > > > Personally I wouldn't use INDEX_NOT_FOUND, as -1 is so well known. > > > > Stephen > > > > ----- Original Message ----- > > From: "Gary Gregory" <[EMAIL PROTECTED]> > > To: "'Jakarta Commons Developers List'" > > <[EMAIL PROTECTED]> > > Sent: Thursday, September 04, 2003 7:22 PM > > Subject: [lang] StringUtils.ordinalIndexOf() and INDEX_NOT_FOUND > > > > > > > Hello All, > > > > > > I've added StringUtils.ordinalIndexOf() and introduced a > > new constant > > > StringUtils.INDEX_NOT_FOUND = -1. Currently, only > > ordinalIndexOf uses > > > this constant. > > > > > > I would like to get a fell if folks think that replacing (where > > > appropriate), the -1 magic number usage in StringUtils with this > > > constant > > is > > > a good idea or refactoring gone wild. > > > > > > Thanks, > > > Gary > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
