Re: Is slowing down bindings updates possible?
Re: Is slowing down bindings updates possible?
- Subject: Re: Is slowing down bindings updates possible?
- From: Marcel Weiher <email@hidden>
- Date: Sun, 05 Feb 2012 10:40:14 +0100
On Jan 19, 2012, at 1:33 , Ken Thomases wrote:
> On Jan 18, 2012, at 6:12 PM, Marcel Weiher wrote:
>> On Jan 14, 2012, at 18:37 , Kyle Sluder wrote:
>>
>>> Breaking this pattern should be a conscious decision.
>>
>> I'd say that the opposite is true: in general you should avoid specific model -> view communication as per MVC (apart from invalidation), but in specialized and very simple cases you may be able to get away with it.
>
> KVO and bindings are not "specific model -> view communication", they are a generalized mechanism which avoid coupling. The model just supports a generalized observer pattern. It doesn't know anything about its observers; it doesn't even know or care whether there are any.
Hi Ken!
I have to admit that my thoughts on this are not 100% formed yet, but while I agree with you in theory, my observations from practice (mostly looking at code provided by people who work(ed) for me) are that this happy theory doesn't pan out in practice.
What I see in KVO and NSNotification code is that instead of noting what has changed, the code immediately acts on that notification, usually by updating the UI. What you then have is not decoupled code, but coupled code (with at least temporal coupling) where the coupling is implicit rather than explicit. To me, implicitly coupled code is actually worse than explicitly coupled code (with actually decoupled code better than either).
That's a fairly high-level wishy-washy type of information, and only my experience, though a very consistent experience.
I think another bit that contributes to this problem is that both KVO and NSNotification call clients directly, rather than going through a queue that could, for example, be used for event coalescing. Because they are called directly, the effect is really very close to inserting a message-send right where you send the notification, and typically there is often only one or at most a couple of potential listeners for that notification, so you might as well just put in a delegate and make the dependency explicit (again assuming my valuation of implicit coupling as worse than explicit coupling is true).
Your mileage may vary,
Marcel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden