On 6/12/07, Daniel N <[EMAIL PROTECTED]> wrote:
>  This is a bit off topic, but could anyone point me at some discussion about
> what the damages controller would look like in this situation.  How much,
> and what code goes into determining what objects are to be setup?

Daniel,

you're right in that it's slightly off-topic and probably a question
better suited to the rubyonrails list (or IRC).  That said, you've
used my example to frame the question so I should probably give *some*
sort of response.

Ultimately, the best advice I can give you is: solve the problem in
front of you in a way that doesn't offend your taste and style.
Here's what I mean:

Personally I like everything to be skinny (not just controllers) so I
tend to have a lot of small and focussed objects that do only one job
(but well, I hope).

I also favor named-route url helpers over generic "give me a url for
these args, I have no idea what they are" because it's more expressive
to me.

I don't automatically create top-level resources that mirror my nested
ones - the idea being expressed has to actually exist (in a business
sense) before it gets a url.

And finally, I find first-pass generalizations are often wrong.  As in
"hey, X is the same as Y" almost always turns into "well, they're
*nearly* the same, I'll just add a few conditionals" which eventually
becomes "oh, I forgot about these cases, I have to add more
conditionals".  After years of doing this I've realized that
developers are very quick to refactor from the specific to the
general, but are often reluctant to refactor  in the opposite
direction (google for "fearofaddingclasses" for related discussions).

So given that entire tug-of-war of my taste and style, the first thing
I (often) reach for is "a specific controller for each route".  I use
a combination of inheritance, mixins and view re-use to avoid
repetition.  Once I have all the specifics nailed I check to make sure
that my strategy isn't getting in the way.  If it is, then it's a
pretty simple matter to pull everything into a single controller to
see how that looks.

You'll get completely different answers from other developers
depending on their taste and style.  Ask the question on the rails
list to get more answers and take them out for a test-drive
(thankfully we're not pouring concrete here).

HTH,
Trevor

-- 
--
Trevor Squires
http://somethinglearned.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to