Signing from the constructor can cause problems for inheritance. Say we have code that looks like this:
public class Parent { public Parent(EventObject source) {
Child ctor calls the Parent ctor, which registers with the event source. However, note that the Child object is not initialized when the Parent registered. If the event source is updated before the Child ctor completes, your code may behave very strange.
An easy way to avoid this problem is to create a subscription within factory methods, which hides ctors.
public class Parent { public static Parent newInstance(EventObject source) { Parent p = new Parent(); source.subscribe(p::someMethod); return p; } protected Parent() {
source share