One of the Dart criticized features are named and factory constructors.
There are opinions (from dependency injection people), that constructors should be simple and just assign some fields and the object graph creation is a responsibility of factories.
There are also some argues against the static methods.
It seems, that Dart constructors bring complexity to constructors. You can not even have a lot of named constructors to create the object in a various ways, you can even have a static factory supposed to construct object of other type than the class it is in.
So, what is the philosophy of Dart and how does it relate (or respond) to the Dependency Injection and no-static state philosophies?
4
Constructors are where you should construct things. That’s why they are so named 🙂
The alternative to constructing everything in the constructor is that you will have a half-constructed object that you then rely on the rest of the program to handle well until its had its properties initialised. This makes things more complicated than they should be – compared to always having a fully constructed object. Martin Fowler talk about this.
I’m not sure about Dart’s philosophy of constructing – if you can’t overload the constructor for different cases, it sounds a bit limiting.
5