Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Distributed Applications / October 2004

Tip: Looking for answers? Try searching our database.

ActiveRecord Pattern and Associations

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason - 12 Oct 2004 12:25 GMT
Hi,

I was experimenting with the ActiveRecord pattern as defined by Martin
Fowler for a small project and was wondering the best way to handle
associations. Should the parent ActiveRecord object (e.g. Order) contain
child collections (e.g. Order.OrderItems), or do you expose methods on the
parent to retrieve the associated data, e.g. Order.GetOrderItems()?

Thanks,

Jason
Sam Santiago - 12 Oct 2004 15:02 GMT
It depends on your application needs.  Do you want to load all associated
data each time, even if you don't need it?  Or do you want to do more of a
lazy load, where you retrieve associated data on demand?  I vote for the
lazy load approach that would return a collection of active records of the
associated type for performance reasons.  Or you could also do a selective
approach where most associations are loaded lazily and others that are
frequently accessed with the parent record are retrieved with the parent.

Good luck.

Thanks,

Sam

Signature

_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTechture.com
_______________________________

> Hi,
>
[quoted text clipped - 7 lines]
>
> Jason
Jason - 20 Oct 2004 08:17 GMT
Hi Sam,

I have used fowlers ghost lazy load pattern in another project that used a
domain model with DataMappers rather than ActiveRecords. In that project, we
used lazy load everywhere and this worked well. However, this only seems to
be compatible with data mappers and no examples are provided for
implementing lazy load when using an ActiveRecord model.

My current way of lazy loading is to expose methods on each ActiveRecord
that retrieve the associated data...is that what you meant by lazy loading
or did you have some other method?

Thanks,

Jason

> It depends on your application needs.  Do you want to load all associated
> data each time, even if you don't need it?  Or do you want to do more of a
[quoted text clipped - 22 lines]
>>
>> Jason
Sam Santiago - 20 Oct 2004 16:04 GMT
Yes, that's what I had been thinking.  Good luck.

Thanks,

Sam

Signature

_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTechture.com
_______________________________

> Hi Sam,
>
[quoted text clipped - 38 lines]
> >>
> >> Jason

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.