What about initializing a variable at the top of the class with a default value? For example:
public class SomeClass {
private int maxRows = 15000;
...
// Inside another method
for (int i = 0; i < maxRows; i++) {
// Do something
}
public void setMaxRows(int maxRows) {
this.maxRows = maxRows;
}
public int getMaxRows() {
return this.maxRows;
}
In this case, 15000 is a magic number (according to CheckStyles). To me, setting a default value is okay. I don't want to have to do:
private static final int DEFAULT_MAX_ROWS = 15000;
private int maxRows = DEFAULT_MAX_ROWS;
Does that make it more difficult to read? I never considered this until I installed CheckStyles.