Which of these 3 approches would choose and why?
// This is the one I would choose
class Car {
}
class FeeCalculator {
public double calculateFee(Car car) {
return 0;
}
}
// in that case the problem might be when we use ORM framework and we try to invoke save with parameter Car
class Car {
private FeeCalculator calculator;
public double calculateFee() {
return calculator.calculateFee(this);
}
}
class FeeCalculator {
public double calculateFee(Car car) {
return 0;
}
}
// in that case the problem mentioned above is solved, but I don't like this design
class Car {
public double calculateFee(FeeCalculator calculator) {
return calculator.calculateFee(this);
}
}
class FeeCalculator {
public double calculateFee(Car car) {
return 0;
}
}