79357813

Date: 2025-01-15 10:24:22
Score: 1
Natty:
Report link

You can implement the logic inside the interface as default implementation. Thus, avoid duplicating it. Refer to https://www.baeldung.com/java-static-default-methods#why-interfaces-need-default-methods for more details.

e.g.

public interface Handler  {
 default Container createComponents(ar1, arg2, arg3) {
  // logic here
 }
}

public class DefaultHandler implements Handler {
}

@ViewScoped
public class SpecificHandler extends DefaultHandler {
}
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Arno