BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Populating objects from a database using "lazy fetch"

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Bruce Wood
Guest





PostPosted: Tue Feb 22, 2005 6:02 pm    Post subject: Populating objects from a database using "lazy fetch" Reply with quote



I'm new to this group, having discovered it via Joanna Carter's posts
to microsoft.public.dotnet.languages.csharp. So, my apologies if this
has already been covered here.

I'm up against an interesting design problem that doesn't seem to be
covered in the GoF book or any other resources I have.

We have a complex business entity (in this case a SalesOrder) that is
related to a lot of other things in the business, and so can have an
enormous amount of information associated with it. It exists in two
tables in a header / detail (sales order / line items) relationship,
but there are myriad other tables that provide auxiliary information
(such as six more tables describing Goods in Transit, etc. etc.)

Our first crack at writing classes for SalesOrder was to say that we
would always read a complete sales order: we would never have, for
example, a sales order with only some of its line items. So far, so
good.

However, as we use SalesOrder in more and more applications, which need
to see more and more aspects of a sales order, the class is becoming
more and more bloated, and more and more expensive to fetch from the
database. Things are beginning to get out of hand.

Can anyone point me to a design pattern that will optimize "lazy
fetches" of information of this type? What I'm hoping for is some
construct that will allow an application to fetch only the parts of the
sales order that it's interested in, either by specifying the items of
interest up front, or by a "lazy fetch" that gets a basic sales order
first and then goes back to the database for more information as the
caller asks for properties of the object that haven't yet been fetched.

The latter was my first reaction to solving the problem, but of course
this introduces massive overhead as well, as the data layer makes
multiple trips back to the database to fetch added aspects of each
sales order on demand. Yuck.

Any ideas on how to solve this problem, knowing that fetching
"everything" up front is becoming thoroughly impractical, and any
"lazy" solution must take into account that queries into the database
for further information are expensive and so must be kept to a minimum?

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.