Doesn't Lazy initialization violate the "Fail Fast" principle? Isn't it better to know if something is bad as fast as possible?
I don't think that one-time initialization will decrease app performance.
Typically you do this for objects that do some form of initialization and it might be beyond just invoking a constructor. I kept things simple for the purposes of the article, but imagine a repository that fetches data from an external API during initialization.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Doesn't Lazy initialization violate the "Fail Fast" principle? Isn't it better to know if something is bad as fast as possible?
I don't think that one-time initialization will decrease app performance.
Typically you do this for objects that do some form of initialization and it might be beyond just invoking a constructor. I kept things simple for the purposes of the article, but imagine a repository that fetches data from an external API during initialization.