From: Trans Date: 2007-02-19T11:49:24+09:00 Subject: Re: More flexible inheritance On Feb 17, 8:40 pm, "Andrew Stone" wrote: > Trans, > > I'm actually in the middle of a week long argument concerning "fat models" > versus "thin models" and with my approach being fat libraries and thin > models. That's a long argument ;) > We have a few sites which will share a lot of functionality and > instead of sharing the models, I like sharing libraries that are included in > the models. The idea being that this is easy to do with svn externals on > the lib directory. Then fix a bug or add functionality in one place. Even > though this gives two places to look for methods, I think it's nice and > clean. > > Even though my example is for a specific implementation, the idea of classes > becoming containers of modules is a great solution to sharing functionality. I think yours is a perfect example. Modules provide SOC and consequently allow one to more easily mix and match aspects to different models. That a class would become exclusively a container of modules (anonymous or explicit) at the very least helps promote a good practice. The only substantial argument against such an approach I've come up is one in preference of delegation over inheritance. If available aspects are modules rather than classes then we are sort-of pushed toward using inheritance, even though in some cases delegation would be preferable. However it's easy enough to maneuver around this if need be, for example: class Module def new(*a,&b) base = self Class.new{ include base }.new(*a,&b) end end > I'm pleased to hear others are thinking this way. Me too. T.