On Mon, Sep 10, 2012 at 11:59 AM, Derek Lin <derek...@hotmail.com> wrote:
> Just want to know the best practices to make sure I get off on the right
> foot.  I think on a general rule, creating fewer instances of an object is
> ideal for performance right?  (I am not suffering any real problems yet)
> In Java, there is Inversion of Control/Dependency Injection.  I have read
> some blog saying that Rails's way is using Modules.  I have to look into
> more on Modules -- for example, are they equivalent to global functions?

People really need to use Modules more and classes less, for example
people often use a singleton class where they should be using a
Module... why should they be using a module? Because that class is
never going to initialized and it's not meant to be... IMO the only
time you use a singleton class is when you are mixing the way
ActiveRecord does when you inherit from it.

You wouldn't believe how many people I see /only/ use a Module when
they plan to inherit from it, and it's kind intriguing they do that
because the way I see it, Modules are (in simplistic terms) organized
groups of code that can run independently or be inherited from.  There
are of course technical differences that make Modules better than
Classes in some cases and Classes better than modules in some cases
but I'm not here to write a book for you.

-- 
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 https://groups.google.com/groups/opt_out.


Reply via email to