Chapter 4. Lazy Sequences – Being Lazy, Being Good
In life, we (hopefully) spend money only on things that we really need. For example, I keep eyeing those ever powerful laptops being advertised every day. I drool over those shiny machines with hefty RAM sizes and lightening processor speed. The buy button is so inviting!
I am sure, at times, you must have felt similar buying urges. However, as you know well, we just don't buy it willy nilly. We think, plan, and buy if we really need it. Simply, because we have limited money, we need to spend it carefully.
A software system, too, has limited resources. When a system needs to acquire an expensive resource, the resource should be obtained when it is really needed,that is at its first use. If the system goes and acquire all expensive resources up front, a reducing lot of overhead would be incurred. Deferring resource acquisition, till it is needed, is an important design principle. For example, a while ago, we looked at...