Tuesday, February 12, 2008

Ah... Bindings and Core Data

As kind of a balance to that last post, I have to say that the last few days exploits with bindings, with some of it intersecting with Core Data, have been a complete joy.

This is, of course, where the dynamic underpinnings of Cocoa/Obj-C really come into their own, and some of the elegant results are almost enough to induce weeping.

As a Cocoa n00b, I'm just beginning to appreciate the zen of Cocoa, but the recurring pattern is quite interesting:
1. Set out to achieve X, decide to investigate the 'right' Cocoa way of doing this
2. Quickly find promising area, excitement rises as I glimpse established patterns and 'depth' of the frameworks to solve the problem
3. Read guides, references - formulate specific vision of how the implementation will be. More excitement/anticipation...
4. Write-test-ARGGH!
5. MOMENTS OF FRUSTRATION (e.g. bindings wrong, nil being messaged somewhere, other unexpected details emerge)
6. *Enlightenment*
7. Joy. Usually bags more respect for NeXT and Apple (in terms of the general patterns of the solution). Occasionally moderated by remaining questions as to why a small feature or convenience is missing.

Like learning any significant library/framework, there's an uphill struggle, but the corpus of successes (and hence working samples that are really meaningful through personalised exercises) accrete rapidly as the general philosophies of the library start to take hold and judgement/first-guesses improve. From the number of guides I've worked through so far, I feel like I'm half way to a good broad-base of coverage of Cocoa - though there's detail everywhere that will remain to discovered on an as-needed basis.

The last time I got stuck into anything this large was probably the Java foundation libraries. Even then, I've been living with Java since 1.0, so have had a chance to accrete knowledge as the libraries have matured. The single biggest difference that stands out (and makes Cocoa much more challenging for the learner in many ways) is the dynamic nature of the language, with all the ensuing mistakes that are bound to happen as you are learning. Coupled with the somewhat simpler debugger (compared with something like the Eclipse tooling these days), and you are left using a fair bit of tracing code to test code paths, print values and learn about sequences of events in the complex library. Nevertheless, the aforementioned moments of 'respect' for the designers of the language and libraries provide ample payback for some of the frustrating moments.

No comments: