Design patterns·Making things
the field is null until the first person asks for it, and the first person asking pays for it.
Lazy initialisation
Also calledlazy init, deferred initialisation, compute on first use
Deferring the creation of something until it is first needed, so startup is cheap and unused things are never built. It moves cost from a predictable moment to an unpredictable one, which is fine for a cache and painful for a database connection opened during the first user request. Under concurrency it stops being a one-liner, which is what double-checked locking is about.