On 5/31/05, Johnny Le <[EMAIL PROTECTED]> wrote:
> However, when I need to display a list of users.  Should I use the query 
> result to display or  should I populate an array of user objects with the 
> query result, and use the array to display?

Use the query result - it's already an OO abstraction. Do not convert
your query to an array of objects - aggregate display pages do not
need objects.

> That is how you would do it in Java.

Not necessarily.

> That means when you use user.getAddress(), it goes back to the database and 
> query the address for that user.

Not necessarily. The user DAO can take care of that completely. As can
the userGateway (which returns a query object).

> If you want to display 10 users with addresses.  You would make 11 trips to 
> the databases.

You might, I wouldn't. I would have my userGateway return a single
query with the appropriate data joined. One trip to the database.

> Now if I use user.getAddress().getCity(), user.getAddress().getState(), 
> user.getAddress().getZip(), it would actually make 31 trips to the database.

Only if you're doing some really 'dumb' objects.

> If you are not using OO, you can just use one join statement and get all the 
> data from database with one trip.  Am I right?

Right, and that's how a data gateway object would work.

> Or am I totally wrong in my approach to OO?

You are seeing "objects everywhere". You need to temper that with an
understanding of design patterns and how they optimize your code.
-- 
Sean A Corfield -- http://corfield.org/
Team Fusebox -- http://fusebox.org/
Got Gmail? -- I have 50, yes 50, invites to give away!

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208161
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to