Topic: Drawbacks to NESTED RESOURCES?

What are the biggest drawbacks to nesting resources?  Is there performance issues involved?  If so what are they and how is it possible to get around this?  Ugly routes are not too much of a concern because of a plugin that turns:

obj_url(@obj4.obj3.obj2.obj.id, @obj3.obj2.obj.id, @obj2.obj.id, @obj.id)

simplifying the above to something like the following:

obj1(@obj4)

I forget the name off the top of my head of the plugin, and can't find the link but i'm sure google can.  My biggest concern is performance.  Thanks in advance for anyone who can shed light on this topic.

Last edited by lambo4jos (2007-05-23 22:49:51)

Re: Drawbacks to NESTED RESOURCES?

If you are talking about ActiveRecords you could hit some issues with the database. Each object needs to be loaded from the database and given you would be talking joins it could be an issue.

It they are "plain" objects it shouldn't matter significantly.

Toby Hede
===================================================
FiniteStateMachine - Software Development for Social Networks
===================================================

Re: Drawbacks to NESTED RESOURCES?

so nesting objects deeply should not matter with the database as long as they are plain objects, or single resources.  But if you are nesting deeply and have joins within the nesting, that could cause bottlenecks? 

I am still unclear.  Anyone know anywhere online that talks about this or does anyone have any other thoughts or explanations? 

Thanks in advance.

Last edited by lambo4jos (2007-05-24 00:31:40)

Re: Drawbacks to NESTED RESOURCES?

If you are talking about ActiveRecords each element requires another query.

Object.childObject results in a  query to populate the Object and another to populate the childObject. You can check the development log to see the queries that are being generated.

You can also play with the loading to get around this.
Ryan has an excellent RailsCast on the basics: http://railscasts.com/episodes/22

If you are talking about straight Ruby objects, not ActiveRecords, references shouldn't matter at all, that's just how OO works.

Toby Hede
===================================================
FiniteStateMachine - Software Development for Social Networks
===================================================

Re: Drawbacks to NESTED RESOURCES?

Thanks for your replies.  I need to start looking at the development logs to see.