From: James Edward Gray II Date: 2010-11-03T05:05:56+09:00 Subject: Re: the dark side of inherited methods On Nov 2, 2010, at 12:02 PM, Josh Cheek wrote: > On Tue, Nov 2, 2010 at 11:19 AM, James Edward Gray II > wrote: > >> Of course, inheritance has it's place and uses but I feel it's definitely >> overused. >> > > Can you give some examples of where it has its place? I have to lay down the law, because there will always be exceptions, but I thought Robert Klemme describes it pretty good a few messages back with the "is a" check. > I realized the only time I ever subclass anything > is ActiveRecord::Base (and I'm not really sure what that offers over > modules, DataMapper uses modules, for example). ActiveRecord is an interesting case of Rubyish inheritance too. It's really a focused DSL, I think. You inherit from ActiveRecord::Base to get a bunch of macros (has_many(), validates_presence_of(), etc.). Using this mini-DSL you describe your model and that changes how the objects produced from that class will behave. It's a build-your-on-class-with-shortcuts system, I think. James Edward Gray II