7 Replies
Most often, when you need some async work done on construction
For example,
Other than that, it's done when some heavier work needs to be done before the instance is complete. Constructors, ideally, should be very simple and lightweight
So it makes sense, ideologically, to have heavy work done in a factory
this is an advanced topic for me now as a biggner
Yes, static factories are not something you would use often
It's not something a beginner should be concerned with much
but its ok to just have the infrmation correct
Sure
ok thank you
2cents:
Constructors should be
- simple
- fast
[citation needed]
My rule of thumb is that if the initialization of objects is rather complicated / async (as mentioned) / or requires stuff that is transformed into what the object actually needs, then I use factory methods.