ericindc wrote:

> I'm working on fixing up the code in my first Rails application and
> have come around to DRYing up the views and partials.  For the most
> part, I'm satisfied with the DRYness of the application, but I have
> 5-6 partials that display nearly identical XHTML, just with different
> content, link_to paths, and images.

This supplements your other answers, which are doubtless technically correct.

The DRY is primarily about the behaviors of methods in an OO design. Having two 
methods that do the exact same thing, but with different labels or a different 
algorithm, is the greatest violation of DRY. (Start by seeing if you can make 
the two methods look more similar, before merging them. If you can't, at least 
find a way to put them right next to each other!)

Similarly, your metadata should be DRY. This is why (and how) Rails obeys 
"convention before configuration". Don't write an XML file saying "our unit 
tests are in the test/ folder". That repeats the information stored in the name 
of the folder.

Now we come to the heart of the matter. HTML, by itself, is not behavior, and 
it's almost not structure. It is mostly art. DRYing two similar stretches of 
HTML is the moral equivalent of DRYing all your #fff and "white" CSS 
directives. 
It's okay if they say the same thing, when they don't use logical statements to 
say them, and when you might not frequently need to change them all at the same 
time.

So that is the answer to "too DRY". Keep DRYing your project until you reach a 
local maximum of convenience, and then don't DRY any more.

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to