Imagine the following Interface:
public interface ActivationFunction {
double calculate(double value);
}
with two similar implementations:
Class based:
public class SignFunction implements ActivationFunction {
@Override
public double calculate(double value) {
return value >= 0.0 ? 1.0 : -1.0;
}
}
...
final SignFunction signFunction = new SignFunction();
Interface based:
public interface SignFunction extends ActivationFunction {
@Override
default double calculate(double value) {
return value >= 0.0 ? 1.0 : -1.0;
}
}
...
final SignFunction signFunction = new SignFunction() {
};
Which of them is preferable and why?
Appreciate for your opinion