2 ms·
From Java pro view: In Java it's a sin to do anything complex in constructors. You only assign fields and maybe, maybe, call some pure static function to assig
by deepsun 7y ago
From Java pro view:
In Java it's a sin to do anything complex in constructors. You only assign fields and maybe, maybe, call some pure static function to assign a computed field.
That mainly comes from unit-testing perspective -- so you can mock the parameters for a unit object _before_ the object does anything.
If you really need to do something complex to initialize those fields, it's better to extract them to different
service class (and call it, ahem, Factory).
So the code looks more like his C example, but wrapped in classes.