Re: The wisdom of the object mentors (Was: Searching OO Associations with RDBMS Persistence Models)

From: Marshall <marshall.spight_at_gmail.com>
Date: 13 Jun 2006 10:22:40 -0700
Message-ID: <1150219360.196003.233550_at_i40g2000cwc.googlegroups.com>


Robert Martin wrote:
> On 2006-06-05 01:52:01 +0200, "Marshall" <marshall.spight_at_gmail.com> said:
>
> > Lazy loading is another "cure" to an iatrogenic disease. If you simply
> > avoid the bad practices being advocated by some here, you won't
> > have any need for nor be able to derive any benefit from lazy loading.
> >
> > If your application needs to access some data, then it has to query
> > it and get access to it before it can proceed. If on the other hand
> > it does not need some data, then it should not query for it.
> >
> > Querying for data you don't need, and failing to query for data
> > you do need, are both results of using the unnecessary abstraction
> > layers that some are advocating. If you simply query for exactly
> > the data you need when you need it, lazy loading becomes
> > irrelevant.
>
> In essence you are saying that indirection is unecessary. This is
> quite provably true. Every program composed of indirection can be
> rewritten without any (though they tend to grow and use lots of flags).
>
> Clearly indirection comes with a cost. It also comes with a benfit.
> Engineering is the balancing act between the two. While Lazy Loading
> can always be eliminating, Lazy loading is sometimes beneficial as an
> indirection technique. It is unwise to reject it out of hand.

You missed my point.

There certainly are things that have associated cost/benefit tradeoffs. Lazy loading is not one of those things.

Caching is an example of something with costs and benefits. You buy access time at a cost of space and latency/freshness. I try to avoid caching because of the costs, but sometimes the application really needs the speed and doesn't need the freshness very much.

Can you state what the benefit of lazy loading is? Note how simply I was able to do so for caching. The benefit can't be just "indirection" because querying is already an indirection. An explicit motivation is needed beyond that; one doesn't require two indirections when the first is fully programmable.

Marshall Received on Tue Jun 13 2006 - 19:22:40 CEST

Original text of this message