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 object is summoned, the flag is tested. If it is ready, it is returned. If not, it is initialized on the spot.

See lazy evaluation for a general treatment of this idea. In heavily imperative languages this pattern carries hidden dangers, as does any programming habit that relies on shared state.

Read more about Lazy Initialization:  The "lazy Factory"

Famous quotes containing the word lazy:

    In clear weather the laziest may look across the Bay as far as Plymouth at a glance, or over the Atlantic as far as human vision reaches, merely raising his eyelids; or if he is too lazy to look after all, he can hardly help hearing the ceaseless dash and roar of the breakers. The restless ocean may at any moment cast up a whale or a wrecked vessel at your feet. All the reporters in the world, the most rapid stenographers, could not report the news it brings.
    Henry David Thoreau (1817–1862)