ipeirotis / Get-Another-Label

Quality control code for estimating the quality of the workers in crowdsourcing environments
70 stars 26 forks source link

Coding style at SummaryReport and Evaluation data #27

Closed ipeirotis closed 12 years ago

ipeirotis commented 12 years ago

I am not sure that I like the approach in SummaryReport:

public <T> Object getAverage(FieldAccessor fieldAcessor, Iterable<T> objects) {
    Double accumulator = 0d;
    long count = 0;
    boolean evalP = fieldAcessor instanceof EvalDatumFieldAccessor;

    for (T object : objects) {
        if (evalP) {
            Datum datum = ((Datum) object);

            if (! datum.isEvaluation())
                continue;
        }

Perhaps we can enforce a convention for returning empty data as "null", independently of the idea of EvaluationData. This special case of checking for instanceof, and then calling a method specific to Datum looks very brittle.

ipeirotis commented 12 years ago

Will skip fixing this one. The code needs a more general refactoring.