-
Notifications
You must be signed in to change notification settings - Fork 28
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
Phase out bindContext
#74
Comments
@mmikeyy I did find a use for |
Ahh!! Hmm... you're catching me in the middle of a rewrite of an old application (from my pre-Geppetto, Marionette, Backbone era, years ago, when I thought I was some sort of Javascript artist, but I was actually just enthusiastically ignorant! The app is cool, though, from a user's perspective, that is, as long as one doesn't lift the hood...) Anyway, all that to say that I'm taking this opportunity to include all the goodies I know of in this rewrite. Including Geppetto.... without I can understand now your puzzlement when I frowned at the announced phasing out of this function. Now that I'm not using it, I tend to find it difficult to see why one would really need it at all. What you are describing seems to be what I was doing with the other application (that I've had to set aside for now) that I'm working on (first Geppetto integration for me). In order for this to work, I need to set Anyway, I figured that this was the natural way to go with Geppetto after reading the documentation, which presents I'm not advocating a return to grace for Something At one point, using One thing that would be good eventually perhaps would be to have some kind of cook book or at least more examples aimed at illustrating different use cases. Too often, examples are presented that are aimed at showing programming prowess rather than easily understood solutions to common problems. I remember an example somewhere that showed Geppetto code, and the writer wrote something like 'ha! and now you're wondering how this code can accomplish anything?? Now let me show you the secret!". And he takes his puzzled reader to some remote javascript file where in just a few lines, the magic is claimed to be unlocked. I find that too often, examples are in a programming style that is so polished that they become enigmas for the casual reader, and in the end, they miss their point which should just be to illustrate a concept as clearly as possible... Well, I've done it again. Really can't stop writing once I get going...:grimacing: So to summarize:
|
Ah, cool!
I agree. It's too easy. And misleading. It should be used only in very specific use cases, not by default.
Agreed. I'd really want to expound on why using Geppetto is a good idea. What problems it solves that are harder to solve w/o it.
Yes it does. I think part of the problem is that it's a class member as well. Which it doesn't have to be. I'd definitely "promote" it to an instance member of Context. Also, it does too much and too little at the same time, it's called
Anyway, I still need @geekdave 's feedback on this (I think he's a bit overwhelmed with work right now). Maybe I'm missing something important here. |
@creynders , I'm running into a problem that seems simple and that I've solved in a way that works but is not ideal at all. Suppose I have a collection that must have a model class. With Geppetto, it seems that the way to go is // context.js
context = Geppetto.Context.extend({
initialize: function() {
this.wireValue('model_class_wired_as_value', model_class)
}
}
);
// collection.js
collection = Backbone.Collection.extend({
wiring: ['model_class_wired_as_value']
,
initialize: function(){
this.model = this.model_class_wired_as_value
}
}
); The reason this seems to be the way to go is that the collection prototype needs a model prototype (not a model instance...). The problem with this however is that values are not wired up.They're just plain values. A model may need to access data through wiring, but it can't when wired as a value. It's accessible for other wired elements, but it's a dead end: it can't access anything else. Wiring a model as a class won't work either as this produces instantiated objects only. The only way that I see to wire a class and still have it available as a class is to wire it as a view. It just works. Even for models or anything else probably. So my feeling is that perhaps it would be a good idea to simply come up with an other term for As much as I like when my program works, I hate to have to write Am I missing something here?:scream: |
No, you're not. This is why I added a Geppetto.Context.prototype.wireFactory = function(key, clazz, wiring){
return this.wireView(key, clazz, wiring);
} Then when v0.7.2 is released all you have to do is remove the monkey patch. |
BTW I'm really interested in your opinion on the fluent syntax, feel free to comment on it in PR-73 I really enjoy our discussions and find them very valuable to get a better understanding on how things work (best) myself. |
Ahh! Excellent! I'll gladly take any function you provide for this, but I just find its name a bit surprising. (especially after our discussion on At the present time, we have:
So we have one verb and different complements, and in each case the action is different. It is also possible (and I do most of my wiring this way) to use a
where each member does the same thing as its method counterpart. Now, if we add Another problem is that I don't see an interesting term for use in the wiring object. Would we have I thought at one point that
I'd go even one step further, and make it more basic than the current In the rare cases when I need to inspect the prototype of a wired class before instantiation, I would know that if I Finally, this leaves open the problem of the wiring object. We can't have: wiring: {
nothing: {},
values: {},
classes: {},
views: {}
} I stop here because I don't want to waste too much time if - who knows - I'm missing something big that is obvious to everyone but me here! I'll have a look at the fluent syntax thing you mention in the other post as soon as I have a chance. I glanced at it already but I did not have the time to really understand it enough to participate in the discussion. |
But that's exactly what you get back from the context in the current implementation ... a factory: a function which creates an instance of a class. Granted, out of convenience it allows for creating instances with I have the most trouble with
Hehe, it really bothers you. I'll think about how we could allow it to be optional. |
yes, but the method name I must concede that I have come to like these factory methods for views. All that bothers me is to have them imposed on me with no way of avoiding them. So... ok, perhaps we could have...
Another idea: to be compatible with the current naming scheme, Ahh! Ideas keep popping up today! Since you don't seem to like my plain [just edited out a paragraph that I had added in the heat of the moment, before I remembered that the chained methods are collectively used as a command, not as a function expected to return a value...] Anyway, I'm stopping here for lack of time (and other things to do!). I'm possibly stealing someone else's ideas that are resurfacing from my subconscious because of that quick glance I had at the other conversation several days ago. If that's the case, no problem: I'm not seeking credit for anything that might be good here. Except for... my plain vanilla |
But the naming scheme is "name=what the method returns".
Yeah, fair enough. Let's fix that in 0.8
That's confusing, inelegant and doesn't communicate intent well IMO. However, I think you'll be glad to see that the basis of the entire fluent interface in #73 is |
Ouch!! I had completely lost sight of the singletons! You're right; they send crashing and burning my understanding of the current naming scheme (i.e. current scheme = verb + what it operates on). For me, So OK!! I understand now that |
I realised I have neglected so far to mention the main reason why constructors are wrapped in the first place: Backbone Collections (and Marionette CollectionViews) maintain their children themselves, e.g. |
First of all:
bindContext
seems to contain only view-related stuff anymore. Maybe it makes more sense to move this to when a view is wired/instantiated.Second: I don't see any advantage of it being a static separate function anymore, or am I missing something @geekdave ?
The text was updated successfully, but these errors were encountered: