From: Robert Klemme Date: 2009-10-13T18:13:54+09:00 Subject: Re: Class Level inheritable attributes - are we there yet? 2009/10/13 ara.t.howard : > i'm simply requesting that the group focus on a good, concrete, > solution for a hard problem instead of simply telling people that the > issue is so easy that it's not even worth solving. Ara, I don't agree to everything you write above especially since - as far as I can see - "the problem" was never stated precisely. But let's not follow that chain of discussion. > i'd love to see some thinking about the various attempts at a complete > solution.  the OP has already noted that the most common are flawed > for even moderately complex use cases, maybe the collective can narrow > in on, and even improve upon, the better ones.  i've personally spent > a week or two trying to solve this problem in the general case and > have found it profoundly slippery to get right.  i've already posted > my attempt at a minimal but complete solution (fattr) but would love > to hear some legitimate and thoughtful analysis of other approaches. > if a particular solution could gain some momentum as being best > practice it would a big help for the next generation of ruby > programmers - so much so that an RCR, or whatever they are called > these days, might really be in order. OK, let's start over. For that first I would like to understand what the problem actually is that needs to be solved here. There are many aspects to this and I would love to see something like a requirements list which particularly states the problem. Questions I have in mind: - Do those attributes need to change or are they set once (quasi / real constant)? - If a subclass inherits a value from the superclass is it supposed to inherit changes to the value as well? - What happens if a super class has its attribute unset? You might want to retain all sub class values - or not. - What happens if a super class has its attribute set? You might want to override all sub class values at this moment. - Must modules along the inheritance chain get their own values or is the feature in question restricted to class instances? (Note, it's almost impossible to include modules here because they may be part of multiple inheritance chains.) - Is the feature expected to work with different combinations to the questions above. Concluding from the complexity you attribute to the problem I assume you can provide more of those guiding questions. Once we have common understanding what the problem is we can start to think about solutions. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/