From: Rick DeNatale Date: 2009-05-26T23:49:12+09:00 Subject: Re: Do you nest classes inside classes? On Tue, May 26, 2009 at 10:38 AM, Simon Chiang wrote: > I sometimes use nested classes to avoid namespace clutter.  The only > downsides I found are related to inheritance, in particular when you > split out classes into different files. > >  [a.rb] >  require 'a/b' >  class A < SuperClass >  end > >  [a/b.rb] >  class A < SuperClass >    class B >    end >  end > > In both files you have to have the correct superclass (which can be > hard during refactoring).  There are different ways to construct this, > however: > >  [a.rb] >  class A < SuperClass >    require 'a/b' >  end > >  [a/b.rb] >  class A::B >  end > > The downside of this is that 'a/b.rb' can't be required on it's own. Sounds like a job for Ruby's not-well-enough-known Module#autoload http://talklikeaduck.denhaven2.com/2009/04/06/all-that-you-might-require -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale