3 ms·
I don't see how it would be more verbose. // you can start with a final concrete class final class A {} var a = new A(); // and later move to inte
by vips7L 4y ago
I don't see how it would be more verbose.
// you can start with a final concrete class
final class A {}
var a = new A();
// and later move to interfaces or abstract types
sealed interface A permits B, C {
public A() {
...
}
}
var a = new A();
Client code would remain the same with the flexibility to refactor to whatever you want later.
- layer8 4y agoI see, yes, if it is possible to make this binary-compatible in the JVM, that would work. One implication is that `new A()` wouldn't be guaranteed to return a new instance anymore (just as for a static method). Personally I still prefer having the ability to name the constructors. I'd rather have "new" be the default constructor name, with the option of having it be something else (i.e. Path.new(...) vs. Path.somethingElse(...)).