Re: The problem with bindings
Re: The problem with bindings
- Subject: Re: The problem with bindings
- From: Steve Sims <email@hidden>
- Date: Thu, 29 Jul 2004 15:05:12 -0400
On 29 Jul 2004, at 14:13, Drew McCormack wrote:
I'm no bindings layer expert, but the little time I have spent using
them, I have found them quite difficult to grasp. Much more so than
the outlet-target approach.
I make extensive use of bindings in FontFX7, and hadn't tried them
before. There was a hurdle to get over in understanding how they work,
but once I got over that it was really easy.
The only difficulty I had was understanding how to design my data
model. I'd been using structs to structure my data, and that's a no-no
with bindings, so I had to do a bit of a redesign.
I usually find that if things go well with bindings, I really can save
that '300 lines of code' that everyone talks about, but when things go
wrong, I can spend hours tracking down the problems, effectively
negating any benefit I may have gained.
Usually when something goes wrong with my bindings it's because I've
bound to the wrong thing, or my NSObjectController instance has a key
spelt wrong.
Furthermore, easy things, like populating a table view with values,
are well documented, and can be achieved very efficiently with
bindings. But try to go a bit deeper, and do something not in the
manual, and it requires a considerable commitment.
I did find the documentation slightly confusing to start, but there's a
few good examples out there of how to do some slightly more difficult
stuff. mmalc's produced some great bindings examples.
It's important to remember that bindings alone might not provide a
complete solution. Making use of methods within your data model to
produce derived values is a very handy technique which complements
bindings. Also remember that bindings is built on KVC and KVO - you
can make use of these things to help your bindings do more complex
things. I really like KVO - all the derived parts of my data model are
generated with KVO. Value transformers are also a handy thing to get
to know.
Basically, it comes down to this: bindings are very hard to debug. You
can't set a breakpoint, so you are left guessing at what is happening
based on an obscure error message from an exception thrown deep in the
Cocoa frameworks. Anyone else have this problem?
The question in my mind here is what is there to debug?
I've never had the bindings system itself crash on me. As I said above
the problems I usually faced have been simple problems in my UI
definition. Otherwise my problems have been with my data model, and
those can be resolved with putting breakpoints inside the appropriate
setter methods.
Steve
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.