1

I need to calculate a score based on various attributes of a Thing t.

How should I implement the class that calculates this?

Option 1:

public class Calculator {
  public static int calculate (Thing t) {
    return subCalculate1(Thing t) + subCalculate2(Thing t);
  }

  private static int subCalculate1 (Thing t) {...};
  private static int subCalculate2 (Thing t) {...};
}

Option 2:

public class Calculator {
  private Thing t;

  public Calculator (Thing t) {
    this.t = t;
  }

  public int calculate() {
    return subCalculate1() + subCalculate2();
  }

  private int subCalculate1 () {...};
  private int subCalculate2 () {...};
}
MetaFight
  • 11,549
  • 3
  • 44
  • 75
gberger
  • 327
  • 1
  • 2
  • 5

0 Answers0