On 01-08-2014 00:30, Benjamin Fleischer wrote:


On Friday, July 25, 2014 11:12:26 AM UTC-5, Rodrigo Rosenfeld Rosas wrote:

     Aaron's recent talk at BigDot Ruby <snip> got me thinking about
    object
    > allocation and the Rails singleton.

     I'm curious, why is this related to that talk

    Do you have any use case where you'd want to instantiate
    Rails::Application that would be better than inherit a new class?

Just thinking about object allocation made me think of the Rails singleton, though I admit the implication of my association is that there would be a case where one would want multiple instance of a Rails object, which is not a case I have thought about.

I also just think of the Singleton pattern as a kind of strange as it's not far removed from being a utility function class. To wit, we call Rails::Application.initialize! but why does that need to fire once on the 'singleton' instance rather that on the class, since class instance variables are a thing. And now that Rails.application behaves very much like Rails::Application's subclass, the distinction is decreasing.


As I see this, even if it's possible to remove the singleton pattern for this class (I don't know if there's some specific reason for it to be a singleton) I'd ask: why should it be changed? If it's just for code styling, then let the Rails core team decide how they prefer the code to be written/read.

Now, if you really think you'd have a valid use case for creating multiple instances of Rails::Application where inheriting a new class from it would be less than ideal, then exposing such use case could certainly trigger a discussion upon removing the Singleton pattern from it. Otherwise I don't think we should argue about code styling in the rails core mailing list as it could easily take all discussion over here about code styling ;)

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to