On IRC, JS just posted an example of how a Person class with regular validations might look: http://rafb.net/paste/results/UnD6ZG15.html Here''s how the Rails 0.9 refactored version looks: http://rafb.net/paste/results/gHymzM53.html Pretty neat ;) -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
Actually, _all_ the stuff in 0.9 looks sweet. Can''t wait to play around with it! (I''ve been putting off updating to the beta/edge stuff). While I''m sure a lot of "purists" has some issues with these kind of things, but for me, it''s stuff like this that makes Rails interesting; that I don''t have to do work that the framework could/should be doing. "sustainable productivity" ;) -- johan On Tue, 14 Dec 2004 13:54:21 +0100, David Heinemeier Hansson <david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org> wrote:> On IRC, JS just posted an example of how a Person class with regular > validations might look: > > http://rafb.net/paste/results/UnD6ZG15.html > > Here''s how the Rails 0.9 refactored version looks: > > http://rafb.net/paste/results/gHymzM53.html > > Pretty neat ;) > -- > David Heinemeier Hansson, > http://www.basecamphq.com/ -- Web-based Project Management > http://www.rubyonrails.org/ -- Web-application framework for Ruby > http://macromates.com/ -- TextMate: Code and markup editor (OS X) > http://www.loudthinking.com/ -- Broadcasting Brain > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Johan Sørensen Professional Futurist www.johansorensen.com
> While I''m sure a lot of "purists" has some issues with these kind of > things, but for me, it''s stuff like this that makes Rails interesting; > that I don''t have to do work that the framework could/should be doing.Yeah, I had a few puristic gripes with it at first. But when I saw how well it was working, those quickly went away. I''ll chose practical application over purity any time of the week. Luckily, what is _really_ pure is often also very practical :) -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
On Tue, 14 Dec 2004 13:54:21 +0100, David Heinemeier Hansson <david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org> wrote:> > Here''s how the Rails 0.9 refactored version looks: > > http://rafb.net/paste/results/gHymzM53.html >In line no. 7, the "unless" keyword is repeated. Is that right? Kind Regards, Ed -- Pretty women make us buy beer, ugly women make us drink beer
> David, what is the intended release date for 0.9?It''s been said so much, but "This Week" (tm) :). No really. The new dispatcher stuff won''t make it in, I just decided. Rails 0.9 already contains so much stuff that''ll it be huge upgrade for most people. Let''s get it out. So over the next couple of days is the plan.> I am developing my masters degree using Rails 0.8.5 and I am heavily > dependant on its productivity gains to pull this one out.Excellent. What project are you working on? -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
David, what is the intended release date for 0.9? I am developing my masters degree using Rails 0.8.5 and I am heavily dependant on its productivity gains to pull this one out. Thanks a lot Demetrius David Heinemeier Hansson wrote:>> While I''m sure a lot of "purists" has some issues with these kind of >> things, but for me, it''s stuff like this that makes Rails interesting; >> that I don''t have to do work that the framework could/should be doing. > > > Yeah, I had a few puristic gripes with it at first. But when I saw how > well it was working, those quickly went away. I''ll chose practical > application over purity any time of the week. Luckily, what is > _really_ pure is often also very practical :) > -- > David Heinemeier Hansson, > http://www.basecamphq.com/ -- Web-based Project Management > http://www.rubyonrails.org/ -- Web-application framework for Ruby > http://macromates.com/ -- TextMate: Code and markup editor (OS X) > http://www.loudthinking.com/ -- Broadcasting Brain > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Edgardo Hames wrote:> On Tue, 14 Dec 2004 13:54:21 +0100, David Heinemeier Hansson wrote: >>Here''s how the Rails 0.9 refactored version looks: >> >>http://rafb.net/paste/results/gHymzM53.html > > In line no. 7, the "unless" keyword is repeated. Is that right?Probably not. Oh and I''d use lambda { ... } instead of Proc.new { ... } on line 7, but I''m not sure if there are any functional differences or if it''s just a personal preference of mine to name the beast by what it''s called. -- Marten Veldthuis
> Good job!Yet another refactoring that leads to even more read-aloud-like code: class Account < ActiveRecord::Base validates_presence_of :subdomain, :name, :email_address, :password validates_uniqueness_of :subdomain validates_acceptance_of :terms_of_service, :on => :create validates_confirmation_of :password, :email_address, :on => :create end "Account validates acceptance of terms of service on create" -- how''s that for literal programming ;) ...along the same lines is the following change that will go in will convert: class Priority belongs_to :account include ActiveRecord::Mixins:list protected def scope_condition "account_id = #{account_id}" end end ...to: class Priority belongs_to :account acts_as_list :scope => :account end -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
On 15/12/2004, at 12:57 PM, David Heinemeier Hansson wrote:>> Good job! > > Yet another refactoring that leads to even more read-aloud-like code: > > class Account < ActiveRecord::Base > validates_presence_of :subdomain, :name, :email_address, > :password > validates_uniqueness_of :subdomain > validates_acceptance_of :terms_of_service, :on => :create > validates_confirmation_of :password, :email_address, :on => :create > endThat is amazing stuff. Can you hear my applause all the way from Australia? --- Justin French http://justinfrench.com http://indent.com.au