argh Java

Jul. 19th, 2007 04:10 pm
gusl: (Default)
[personal profile] gusl
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:

		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++;
		}
		
(will be screened)
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags