Jump to content

Lazy initialization

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ed Poor (talk | contribs) at 21:35, 27 September 2002 (73 bytes longer, and this would no longer be a stub!!!). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Lazy initialization in computer programming is the tactic of delaying the creation of an object, the calculation of a value or some other expensive process until the first time it is needed.

This is typically accomplished by maintaining a flag indicating whether the process has taken place. Each time the desired thing is summoned, the flag is tested. If it's ready, it is returned. If not, it is initialized on the spot.