#3 Define manifest constant for smallest internal record id

open
Rick Hall
1
2010-10-19
2010-10-19
Rick Hall
No

Internal record ids are created in the range 0 to Integer.MAX_VALUE. At some points in the code, the limits are used explicitly, which can be confusing or appear to be an implicit bug waiting to happen. An example:

package com.choicemaker.cm.io.blocking.automated.offline.services
class OABABlockingService
method removeDups(LongArrayList x)
line 443

private LongArrayList removeDups (LongArrayList osIDs) {
osIDs.sort();

LongArrayList newList = new LongArrayList (100);

// NOTE Not a bug 2010-10-19 rphall
// This can assume record ids > 0, because it refers to internal ids,
// which are 0 or greater. It would be nice to define a manifest constant
// for this magic number, however.
long last = -1;
// ENDNOTE
for (int i=0;i <osIDs.size(); i++) {
if (osIDs.get(i) != last) {
last = osIDs.get(i);
newList.add(last);
}
}

return newList;
}

Discussion