Robert Walker wrote:
[...]
> Personally, I like the pattern of having separate formatter classes, but 
> using view helpers isn't too bad. For example the Cocoa framework 
> provides NSDateFormatter and NSNumberFormatter. Java also has the 
> SimpleDateFormat class for this purpose. And, responsibility for I18n 
> can be delegated to the formatter classes as well.
> 
> I like this pattern because the view layer should be responsible for 
> formatting values for display. Since Date and Time are model objects 
> they really should not be responsible for formatting their own data.

I think I'm going to take issue with this statement.  It seems to me 
that model objects *should* know how to format themselves as strings -- 
after all, that's part of the class' interface to its clients. 
Formatter classes may be useful in a language like Java, where you can't 
reopen Date to add new formats, but at least for simple cases, I fail to 
see how they're anything but a design smell in Ruby.

> 
> But, I realize that opinions vary.

Yes.  And it may be that your approach has some benefits that I haven't 
thought of...
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to