The following piece of code is redundant, in a bad way. The first half prints adjacency-evaluation data. The second half, which is almost identical, prints coefficient-evaluation data. The only difference between them is the set of "System.out" statements inside the inner loop.
The right thing to do should be to refactor it, by pushing the outer loop into a new method, and passing to this method the set of properties to be recorded.
But how can I pass properties in Java? Do I need to turn them into Strings and use reflection?
Here's the code:
The right thing to do should be to refactor it, by pushing the outer loop into a new method, and passing to this method the set of properties to be recorded.
But how can I pass properties in Java? Do I need to turn them into Strings and use reflection?
Here's the code:
System.out.println("************************************************************************");
System.out.println("*** comparing runs for this setting: adjacency (errOmission,errCommission,loss) ***");
System.out.println("************************************************************************");
//for each run
for (List run : evalTable){
String s = "#" + i + ":" + __;
//for each method, show omission, commission and loss
for(EvaluationResult eval : run){
s += eval.adj.errorsOfOmission + _;
s += eval.adj.errorsOfCommission + _;
s += eval.adj.loss() + __;
}
//s+=winner;
System.out.println(s);
i++;
}
System.out.println("************************************************************************");
System.out.println("*** comparing runs for this setting: all coefficients (total_loss) ***");
System.out.println("************************************************************************");
i=0; //run-number
//for each run
for (List run : evalTable){
System.out.print("#" + i + ":" + __);
//for each method, show omission, commission and loss
for(EvaluationResult eval : run){
System.out.print(eval.coeffAll.loss() + _);
}
//s+=winner;
System.out.println("");
i++;
}
(no subject)
Date: 2007-07-19 11:25 pm (UTC)(no subject)
Date: 2007-07-19 11:35 pm (UTC)I could push the code into an abstract class, and use a different set of properties in each subclass. But that would be just as redundant as what I have now.
The outer and inner loops should appear exactly once in my code.
(no subject)
Date: 2007-07-20 12:44 am (UTC)(no subject)
Date: 2007-07-20 02:20 am (UTC)(no subject)
Date: 2007-07-20 02:29 am (UTC)(no subject)
Date: 2007-07-20 06:59 am (UTC)(no subject)
Date: 2007-07-20 01:48 pm (UTC)(no subject)
Date: 2007-07-20 07:19 am (UTC)