On 07/12/2011 08:42 AM, Conrad Taylor wrote:
The above class can be refactored as to the following:
class SiteFactory
def self.create( site )
site.new
end
end
I'm just curious, what exactly is the point of this class?
Now, we can rewrite our calling routine to the following:
[ HerSite, HisSite ].each do | klass |
site = SiteFactory.create( klass )
Spider.crawl_site( site )
end
Seems needlessly verbose, why not just get rid of the factory that isn't
doing anything and just do...
[ HerSite, HisSite ].each do | klass |
Spider.crawl_site(klass.new)
end
In fact, why not just...
Site.subclasses.each { | klass | Spider.crawl_site(klass.new) }
Forgive me, I'm a Smalltalker, but this whole explicit factory business
and explicit arrays of classes just looks too Java'ish in an object
system with meta classes and reflection. Is there some reason you
wouldn't just reflect the subclasses? Is there some reason for a
factory that does nothing? Even if you need a factory, why wouldn't you
just use class methods on Site?
--
Ramon Leon
http://onsmalltalk.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.