From: Chad Fowler Date: 2003-02-12T01:48:09+09:00 Subject: Re: inheriting from base classes Michael Campbell wrote: >>But a further question is: how fundamental is the inheritance >>hierarchy >>to designing programs in Ruby, given the non-kind_of? underpinnings >>of >>Ruby objects (i.e., their dynanism and "in-the-moment" behavior)? >> >> > > >Are you saying here that because it's easy to not do strict kind-of? >modelling in ruby, that you shouldn't? Or that existing classes in >ruby don't do it, so end users shouldn't have to? Or something else? > >Your previous post seemed to indicate you break the kind-of? "rule of >thumb" where it becomes convenient to save typing, which I think is >not the way it should be done. not that I've never done the same >thing, but we're at a more conceptual level with this discussion. >(Or are we? maybe that's a disconnect.) > > > > I wouldn't say this is an issue of saving typing (as in pushing keys on a keyboard). My guess is that David feels that this is the "Ruby spirit". I'm a static->dynamic language convert (not that I'm going to preach about either), and while I understand all of the is-a/has-a stuff and have practiced it for years, I find that in Ruby I stop worrying about type so much. I give myself a lot more flexibility to be expressive and succinct. Maybe I'll add a method to an existing class. Maybe to an instance. In languages like Java, I tend to *never* use the equivalent of Ruby's Array in public interfaces, because I'm so driven by the Java strict typing Way. So, I see where David's coming from here. There are rules of thumb on OO design, but the Ruby environment places higher value on "responds-to?" than "is-a?" ...at least in my interpretation of it. That having been said, these days I find myself (in Ruby, at least) almost never inheriting from anything. Again, I'm not dogmatically saying that you *shouldn't* use inheritance. I just tend to do what a) feels right, b) gets the job done, and c) others can read (if that's even necessary). Chad