Re: The problem with bindings
Re: The problem with bindings
- Subject: Re: The problem with bindings
- From: James DiPalma <email@hidden>
- Date: Fri, 30 Jul 2004 17:37:19 -0700
Thank you for bringing this discussion to cocoa-dev; I have
participated in many similar discussions and have found myself
defending my intelligence and understanding rather than discussing how
this technology might be improved. Its unfortunately part of our
community: because you understand a technology, are certainly capable
of using this technology, and have some concerns, means that you are
less than a forceful wave of programmers who happily use this
technology for its functionality.
I have discussed many things: bindings, NSDocument, NSWindowController,
NSTableView, and others. These technologies have true functionality,
but as a community we seem to value functionality greater than design
(and always seem to value compatibility greater than either consistency
or design).
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.
Yes. When I was more involved with supporting InterfaceBuilder, I saw
many beginners scratch their heads a few times before undestanding
target/action, outlets, and how these patterns connected to and
affected their code. Bindings are far more difficult to understand
partly because they are less tangible: outlets ivars written into your
header file and prefixed with IBOutlet, target is simply an IBOutlet
that is connected along with an action, actions are methods implemented
by your targets. Simple.
Bindings are undocumented (except by their listing in IB) identifiers
with undocumented (but sometimes/often implied) behavior that will
often trigger further undocumented but useful behavior and sometimes
other bindings.
I usually find that if things go well with bindings, I really can save
that '300 lines of code' that everyone talks about,
Anything that a programmer does should be considered similar to lines
of code; bindings need to be "written", maintained, debugged, and maybe
localized just like code, so sometimes saving lines of code isn't
really saving lines of code.
There are also secondary advantages to code: breakpoints work within
code, code can be copy/pasted, object reuse by nib instantiation is
often easier than reestablishing a set of bindings, outlets/actions can
be added to objects without writing an IB palette, code completion and
compile time checking can make typing identifiers easier and more
reliable. Also, code can be more flexible (or can adapt more simply) to
handle subtle problems (a defaults controller has difficulty pulling a
single value from within an array). A need for code based solutions can
introduce inconsistencies: consider drag/drop and other table view
problems: data source api, delegate api, bindings, and
NSArrayController all combine to make a solution that feels self
inconsistent (converting between rows as an array of NSNumber objects
and rows as an NSIndexSet).
but when things go wrong, I can spend hours tracking down the
problems, effectively negating any benefit I may have gained.
Furthermore, easy things, like populating a table view with values,
are well documented, and can be achieved very efficiently with
bindings.
Technology introduced along with bindings makes writing a data source
that fills a table view very efficient (about 10 lines of code to
display single values and allow sorting). NSArrayController does so
much more that when we want to go further than these 10 lines of code,
NSArrayController becomes interesting.
None of these advantages to code make bindings useless; bindings have
true functionality that can't be matched by each individual programmer
writing their own solutions. But, we should try to understand bindings
while also trying to understand code based alternatives. Is there a
better solution? a better investment for Apple's time? maybe, but it
doesn't really matter: we have bindings (they aren't going away) and
Apple's time is already spent.
-jim
_______________________________________________
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.