Using associations or better avoiding?

i am wondering if its good to use associations where possible or if its
better to avoid them …

my concern is: it could lower the performance of my application (because
new methods are added to the models which are not all necessary for me,
etc.)

as i am new to ror development i need some expertise advice on this …
can it lead to problem when using associations everywhere where
possible?

thanks for your opinion…

Associations provide a higher level of abstraction for your app. How
does
adding new methods affect performance?

You can optimize slow queries with multiple joins by using sql instead
of
ActiveRecord finders. There are also other techniques to speed up the
app.
As a beginner I would not worry.

As one of my incompetent manager used to say: “Code like a wind”. LOL.

On Dec 21, 2007 12:42 PM, Michal G. <
[email protected]> wrote:

i am wondering if its good to use associations where possible or if its
better to avoid them …

my concern is: it could lower the performance of my application (because
new methods are added to the models which are not all necessary for me,
etc.)


http://www.rubyplus.org/
Free Ruby Screencasts

thanks for your quick reply … so lets say i have a User model which
has the following attributes…

firstname
lastname
creator_id
updater_id
reports_to

so the user was created by a user … and the last modification be done
by another user … then each user reports to one user … moreover the
users have friends, send messages, write blog entries, etc.

  • would you really add for all this own associations? also e.g. for
    creator and updater - which are e.g. only used on one place?

  • i also load the current logged in user on each request … would this
    affect performance if more associations are here?

i am just wondering, because the project is expecting to have 10.000
uniques a day.

Remember what they say about premature optimization :slight_smile: ?

Fred

yeah you are right … but thats why i am asking … if its not that big
deal then i will use it all the way :slight_smile: because its a great feature!

associations are one of the benefits of using rails. You should be
happy to be able to use them!

Adam

On 21 Dec 2007, at 20:58, Michal G. wrote:

so the user was created by a user … and the last modification be done
by another user … then each user reports to one user … moreover the
users have friends, send messages, write blog entries, etc.

  • would you really add for all this own associations? also e.g. for
    creator and updater - which are e.g. only used on one place?

probably

  • i also load the current logged in user on each request … would this
    affect performance if more associations are here?

Having an association or not isn’t going to affect the loading a
single record

i am just wondering, because the project is expecting to have 10.000
uniques a day.

Remember what they say about premature optimization :slight_smile: ?

Fred

thanks… i wasnt so sure about this. now i am using associations
everywhere :slight_smile:

it could lower the performance of my application (because
new methods are added to the models which are not all necessary for me

Just to be clear, the number of methods in a class has neglible impact
on performance, so I think your concerns about associations are maybe
based on a false premise.

///ark

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs