Magic Numbers
Our code guidelines state clearly that "magic number" are not permitted. We run Checkstyle to pick up style related violations. So, despite this, what do I find when I'm poking around fixing something unrelated?
The values above were used to index the result of this:
Ignore the fact that a pipe separated string might not be the ideal way to send this data. That's another topic altogether. Ignore that fact that elements 0, 1 and 2 were indexed with hard coded numbers. I still don't fathom what was the point of going to this much effort and still not giving the constants meaningul names. And yes, the code used these to index the array and set the values to attributes of the class.
private static final int PARAM_INDEX_THREE = 3;
private static final int PARAM_INDEX_FOUR = 4;
private static final int PARAM_INDEX_FIVE = 5;
private static final int PARAM_INDEX_SIX = 6;
private static final int PARAM_INDEX_SEVEN = 7;
private static final int PARAM_INDEX_EIGHT = 8;
private static final int PARAM_INDEX_NINE = 9;
private static final int PARAM_INDEX_TEN = 10;
The values above were used to index the result of this:
String [] fields = record.split ("\\|");
Ignore the fact that a pipe separated string might not be the ideal way to send this data. That's another topic altogether. Ignore that fact that elements 0, 1 and 2 were indexed with hard coded numbers. I still don't fathom what was the point of going to this much effort and still not giving the constants meaningul names. And yes, the code used these to index the array and set the values to attributes of the class.
0 Comments:
Post a Comment
<< Home