-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixin inheritance chain doesn't work correctly #14
Comments
So I see two issues to correct. 1) too many levels of dependency (4). 2) What would work for a simpler model? On Wed, May 23, 2012 at 2:31 PM, Eric Watson <
|
Here's one possibility: For Shoes classes, we add an instance variable that acts as the point of interaction with the backend. So instead of this: class Shoes::Button
def initialize(...)
gui_init
end
end
module SwtShoes::Button
def gui_init
end
end we have this: class Shoes::Button
def initialize(...)
# Create appropriate class using Shoes.configuration.framework
@gui = Shoes.gui_for(self) # @gui.class == SwtShoes::Button
@gui.init
end
end
class SwtShoes::Button
def init
end
end in purple_shoes, ashbb uses To increase testability of the Shoes classes, we can allow the framework class to be passed into the constructor: class Shoes::Button
def initialize(args={})
@gui = args[:gui] || Shoes.gui_for(self)
@gui.init
end
end The key wins are
|
HI Eric, Ok, what you demonstrate makes total sense, and I would have to think for a 2 Questions : Looking forward to your thoughts. On Wed, May 23, 2012 at 3:57 PM, Eric Watson <
|
I had to code lots of classes before I ran into a problem with this structure, so I think it was a completely reasonable idea. We adapt. 2 Answers: A: Yes, currently, A: Hmmm. I think we could go either way on this.
I think it makes more sense to namespace like
Thoughts? |
Ok. I agree with your design. So Shoes::Animation is loaded, then by framework-loader, Should the GUI interface use before/after hooks to do its work? Do you Peter Fitzgibbons On Wed, May 23, 2012 at 10:20 PM, Eric Watson <
|
HI Eric, I created Shoes4 issue #4 : Fix mixin/inheritance chain We can continue our discussion there. Peter Fitzgibbons On Thu, May 24, 2012 at 5:35 AM, Peter Fitzgibbons <
|
Consider this scenario: I am writing
SwtShoes::CommonMethods
. I can easily overwrite methods inShoes::CommonMethods
by defining them in my module, because the inheritance chain goes like this:Now say I want to override a method on
SwtShoes::Button
. If I try this inSwtShoes::Button
, my methods do not override methods inShoes::Button
, because of the same inheritance chain. This is confusing, and incorrect in the sense thatSwtShoes::Button
ought to have the first crack at the behavior, since it is the most specific of the modules/classes.After working with this structure for a while, I think that we should try adding framework-specific behavior to Shoes classes (e.g.
Shoes::Button
) through composition instead of mixins. For modules (e.g.Shoes::CommonMethods
), simply mixing in a framework-specific module seems to work. Testing a module is harder, though, than testing a class, especially when the module depends on state, which lots do in Shoes.The text was updated successfully, but these errors were encountered: