DEV Community

Discussion on: Getting Lazy in C#

Collapse
 
nikaszalias profile image
NikasZalias

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.

Collapse
 
integerman profile image
Matt Eland

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.