I know that bad (security) practice calls overriden methods from an object constructor in Java. However, for example, if the constructor needs to initialize some data, it seems reasonable to call the appropriate configuration method so that I do not copy the code. The installations are public, not final. Is there any standard way to deal with this, for example, declaring private setter methods that public call? To illustrate, here is the code:
class A {
private double x,y;
private privateSetX(double x1) { x=x1; }
private privateSetY(double y1) { y=y1; }
public A() { privateSetX(0); privateSetY(0); }
public setX(double x1) { privateSetX(x1); }
public setY(double y1) { privateSetY(y1); }
};
source
share