Re: ADC Core Data article
Re: ADC Core Data article
- Subject: Re: ADC Core Data article
- From: Marco Scheurer <email@hidden>
- Date: Thu, 7 Apr 2005 17:55:22 +0200
On Apr 7, 2005, at 4:55 PM, Marcel Weiher wrote:
On 7 Apr 2005, at 14:11, Charlton Wilbur wrote:
On Apr 7, 2005, at 5:59 AM, Marcel Weiher wrote:
Sure does!
result = [employee valueForKey:@"name"];
vs.
result = [employee name];
The second is:
1. Expressed directly in the target language (Occam's Razor,
anyone?)
2. More compact
3. Easier to read
4. About an order of magnitude faster ( about 8 times, to be a
bit more precise )
[...]
How much longer does it take to dispatch a method call instead of
just calling a function? If you wrote the whole thing in one long
continuous stream of PowerPC assembly, it would be still faster,
because you could hand-optimize the assembly and get it to run REALLY
quickly!
Hmm...you did notice that performance was only 1 of the 4 points I
mentioned? My main point is about expressing intent clearly.
And you forgot (or considered it part of 1.):
5. The compiler is likely to warn you if employee does not respond to
name.
Of course, this is not a sign that either is better -- programmers
get significant benefits from using C instead of assembly, and from
using Objective-C instead of C, and from using bindings instead of
straight method calls.
While I agree that KVC and bindings can provide benefits, I am not
convinced that embedding a string-based mini-language is the best way
to obtain those benefits. It certainly has significant drawbacks.
I like bindings. Being able to hookup as easily a control or preference
panel, not having to write all these synchronization methods between
your model and your view is really neat. And in some case the result is
likely to be more optimized than what you would care to do by hand (for
instance redrawing a single cell in a table view when one attribute of
one object in a collection changes vs using reloadData).
But I've never been a fan of KVC per se. In fact I consider using
[employee valueForKey:@"name"] in one's code an ugly fault of style.
Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden