-
Notifications
You must be signed in to change notification settings - Fork 69
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
Revisiting differential inheritance - extend by default? #42
Comments
First, let me say I am not experiencing problems related to that now, so I will just give my totally unbased opinion. For controllers, a call to "this.parent.create.call(this)" could be enough to get the parent "create" behavior. It seems simple to implement and is similar to the javascript inheritance behavior. For style, I would prefer to always extend, and not having a way to disable it. It's more similar to the way we operate on css files. |
I think properties that can be extended should have that behavior by default, with the ! syntax to override. |
In my opinion, the If the default behavior is to extend the previous function, then As to what the default should be, I've made an argument before that differential inheritance is the JavaScript default, and having that as the default makes it consistent with the language. But I'm all for what's more intuitive to use, and for my part after looking at the guts of Agility for a while, it's all the same to me. |
The use of ! makes sense to me. However, I haven't started using Agility heavily yet, so my word shouldn't be taken as law. |
OK, let's keep things as they are for now (using |
This debate has been sparked by the work of @tristanls, who implemented the extend (
~
) syntax for controllers.Originally, Agility tried to stick to a differential inheritance paradigm. This meant that all properties of Agility objects were passed on to their descendants as prototype methods, except when overridden by the children:
That was not the desired behavior, mainly because there would be no way to extend previously defined controllers. So @tristanls proposed the new syntax
~
for controllers, which would allow one to keep the previously defined handlercreate
, and add some more logic to it:Then Darren Mason pointed out that a similar issue arises with CSS styles:
Again, @tristanls proposed a similar solution:
This seems to reveal a pattern - whenever some properties can be extended, it seems like the desired default behavior is to extend, and not override. This includes CSS styles and controllers. (There doesn't seem to exist a way to naturally extend models and formats, so these would have to be overridden by default).
So I am considering the possibility to make extend the default behavior for controllers and styles, and to introduce a new syntax
!
to allow children objects to override inherited properties, e.g.The pros and cons I can see are:
What do you think?
The text was updated successfully, but these errors were encountered: