Main Page | See live article | Alphabetical index

Lazy initialization

In computer programming, lazy initialization 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.