|
|
|
|
|
by kazinator
3344 days ago
|
|
Over-engineered construction schemes are a result of multiple factors. One is simply the static type system which gives rise to overly rigid type signatures. Class constructors tend to exhibit a variety of type signature. Even when objects are derived from the same base type and substituted for each other, the way they are constructed can be quite different. In a dynamic language, we can handle all construction with the same kind of function: something that takes a "property list". Because of that, we can have a "virtual constructor". That can be a method on a meta-class to create an instance, or just something built in: some make-new-object function which takes a type and a list of generic constructor arguments that any type can handle. This is very easy to indirect upon. Adding meta-classes in Java wouldn't solve the problem of how to make construction generic. |
|