Skip navigation.
 
mlRe: ADC Core Data article
FROM : Marcel Weiher
DATE : Thu Apr 07 19:13:16 2005

On 7 Apr 2005, at 16:55, Marco Scheurer wrote:

> [ valueForKey:@"name" vs. name


> And you forgot (or considered it part of 1.):
>
> 5. The compiler is likely to warn you if employee does not respond 
> to name.


Yes, that is part of the larger issue of embedding (mini-)languages 
in other languages:  your original language will typically know 
nothing about your embedded language, and therefore can't even check 
if it is even syntactically OK at the coarsest level.  Same applies 
to SQL-like query languages or XQuery expressions etc.

On the other hand, the expressiveness gained by these mini-languages 
is significant.  So what to do?  I think a promising path is to allow 
the original language to be extended in a controlled fashion.

For example, when something like KVC was needed in ThingLab ( ca. 
1979 )(1), they just extended the Smalltalk system they were using to 
allow path expressions to be used directly in the language.  That's 
one part of the equation.  The other part is reifying the concept of 
reference, so that you have a "reference" object that provides access 
to another object (usually relative to a base object).

For example, MPWFoundation provides a "soft pointer", which is really 
nothing but a reified variable (something very similar was recently 
suggested to 'untangle' object oriented composition).  To stay with 
the example, you might initialize such a soft pointer using a HOM:

    softPointer = [[employee reference] name];

Now you can use this soft-pointer very much like you would have used 
a KVC path, but without having to use an unchecked string, and 
without having to reparse that string every time the reference is 
used.  (Of course, it is also possible to use a string to initialize 
the pointer, but strings dont' become a fundamental means of 
communicating such references).

>

>>> 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).


Definitely.  Programming with constraint systems definitely makes a 
lot of things a lot easier, as they take care of a lot of mundane 
data shuffling.  In fact, full-fledged constraint systems do a lot 
more, keeping a whole set of variables/parameters consistent 
according to global equations (keeping stuff in sync is a subset 
where the only operation allowed in constraint equations is equality).

However, I would much prefer a system that would allow me to express 
those constraints *directly*, just like I can now specify message 
sends directly (instead of indirectly, for example by parametrizing 
objc_msgSend() ).  Coming back to ThingLab, it just had a 
"constraints" section:

Part Descriptions

Line: a line

midpoint: a point

Constraints

(line point1 + line point2) /2 = midpoint

midpoint ¬ (line point1 + Line point2) / 2

Line point1 ¬ line point2 + ((midpoint-Line point2)*2)

Line point2 ¬ line point1 + ((midpoint-Line point1)*2)


The system would now make sure that these constraints always held: 
if you changed the end-points, the midpoint would be recalculated, if 
you changed the mid-point, the end-point(s) would be adjusted.   
Objects with these constraints could be composed, so multiple 
constraints (in a hierarchy) were considered to arrive at the final 
values.  The application to keeping UI synchronized with model 
objects is hopefully obvious. :-)


> 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.


Yes, I agree.

Marcel


(1)
@article{357147,
  author = {Alan Borning},
  title = {The Programming Language Aspects of ThingLab, a Constraint-
Oriented Simulation Laboratory},
  journal = {ACM Trans. Program. Lang. Syst.},
  volume = ,
  number = ,
  year = ,
  issn = ,
  pages = ,
  doi = {http://doi.acm.org/10.1145/357146.357147},
  publisher = {ACM Press},
  address = {New York, NY, USA},
  }

(2)
@inproceedings{504303,
  author = {Klaus Ostermann and Mira Mezini},
  title = {Object-oriented composition untangled},
  booktitle = {OOPSLA '01: Proceedings of the 16th ACM SIGPLAN 
conference on Object oriented programming, systems, languages, and 
applications},
  year = ,
  isbn = ,
  pages = ,
  location = {Tampa Bay, FL, USA},
  doi = {http://doi.acm.org/10.1145/504282.504303},
  publisher = {ACM Press},
  address = {New York, NY, USA},
  }


--
Marcel Weiher                Metaobject Software Technologies
<email_removed>        www.metaobject.com
Metaprogramming for the Graphic Arts.  HOM, IDEAs, MetaAd etc.
        1d480c25f397c4786386135f8e8938e4

Related mailsAuthorDate
mlADC Core Data article mmalcolm crawford Apr 5, 17:33
mlRe: ADC Core Data article Philip Mötteli Apr 5, 23:49
mlRe: ADC Core Data article Guy English Apr 6, 00:29
mlRe: ADC Core Data article Scott Stevenson Apr 6, 01:14
mlRe: ADC Core Data article Dustin Voss Apr 6, 02:18
mlRe: ADC Core Data article James Duncan David… Apr 6, 02:27
mlRe: ADC Core Data article Jake Macmullin Apr 6, 02:31
mlRe: ADC Core Data article John C. Randolph Apr 6, 02:55
mlRe: ADC Core Data article James Duncan David… Apr 6, 03:01
mlRe: ADC Core Data article Ondra Cada Apr 6, 04:04
mlRe: ADC Core Data article Will Mason Apr 6, 04:48
mlRe: ADC Core Data article Rogelio M.Serrano… Apr 6, 06:05
mlRe: ADC Core Data article Rogelio M.Serrano… Apr 6, 06:06
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 07:46
mlRe: ADC Core Data article Paul Szego Apr 6, 08:22
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 09:52
mlRe: ADC Core Data article ?????Andre? Apr 6, 09:55
mlRe: ADC Core Data article Ondra Cada Apr 6, 12:21
mlRe: ADC Core Data article oplus Apr 6, 12:32
mlRe: ADC Core Data article Mont Rothstein Apr 6, 12:36
mlRe: ADC Core Data article Philip Mötteli Apr 6, 14:47
mlRe: ADC Core Data article Scott Stevenson Apr 6, 18:00
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 18:39
mlRe: ADC Core Data article Nat! Apr 6, 22:35
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 23:47
mlRe: ADC Core Data article Timothy Reaves Apr 7, 00:25
mlRe: ADC Core Data article mmalcolm crawford Apr 7, 00:50
mlRe: ADC Core Data article Shawn Erickson Apr 7, 01:05
mlRe: ADC Core Data article James Duncan David… Apr 7, 01:28
mlRe: ADC Core Data article Todd Blanchard Apr 7, 06:37
mlRe: ADC Core Data article Todd Blanchard Apr 7, 06:41
mlRe: ADC Core Data article Scott Stevenson Apr 7, 06:59
mlRe: ADC Core Data article Philip Mötteli Apr 7, 08:32
mlRe: ADC Core Data article Marcel Weiher Apr 7, 11:59
mlRe: ADC Core Data article Charlton Wilbur Apr 7, 15:11
mlRe: ADC Core Data article Mike Ferris Apr 7, 16:53
mlRe: ADC Core Data article Marcel Weiher Apr 7, 16:55
mlRe: ADC Core Data article Marco Scheurer Apr 7, 17:55
mlRe: ADC Core Data article Marcel Weiher Apr 7, 19:13
mlRe: ADC Core Data article Scott Stevenson Apr 7, 19:55
mlRe: ADC Core Data article Marcel Weiher Apr 7, 21:03
mlRe: ADC Core Data article Mike R. Manzano Apr 7, 21:21
mlRe: ADC Core Data article Timothy Reaves Apr 7, 22:03
mlRe: ADC Core Data article Evan DiBiase Apr 7, 22:28
mlconstraint satisfaction (was: ADC Core Data article) Marcel Weiher Apr 7, 22:35
mlRe: ADC Core Data article mmalcolm crawford Apr 7, 23:05
mlRe: Re: ADC Core Data article ttempel Apr 8, 01:50
mlRe: ADC Core Data article Paul Szego Apr 8, 11:50
mlRe: ADC Core Data article Johnny Deadman Apr 8, 14:10
mlRe: ADC Core Data article Philippe Mougin Apr 8, 16:52
mlRe: ADC Core Data article Shawn Erickson Apr 8, 17:07
mlRe: ADC Core Data article Shawn Erickson Apr 8, 17:17
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 17:28
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 17:32
mlRe: ADC Core Data article John Brownlow Apr 8, 17:47
mlRe: ADC Core Data article Charlton Wilbur Apr 8, 18:34
mlRe: ADC Core Data article Scott Stevenson Apr 8, 18:43
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 19:03
mlRe: ADC Core Data article Philippe Mougin Apr 8, 20:37
mlRe: ADC Core Data article Scott Ellsworth Apr 8, 21:46
mlRe: ADC Core Data article Scott Ellsworth Apr 8, 21:48
mlRe: ADC Core Data article Evan DiBiase Apr 8, 22:16
mlRe: ADC Core Data article mmalcolm crawford Apr 8, 22:30
mlRe: ADC Core Data article mmalcolm crawford Apr 8, 23:13
mlRe: ADC Core Data article Marcel Weiher Apr 9, 02:20
mlRe: ADC Core Data article Marcel Weiher Apr 9, 02:46
mlRe: ADC Core Data article Scott Ellsworth Apr 9, 09:39
mlRe: ADC Core Data article Marcel Weiher Apr 9, 09:44
mlRe: ADC Core Data article Byron Ellis Apr 9, 10:37
mlRe: ADC Core Data article Marcel Weiher Apr 9, 14:03
mlRe: ADC Core Data article Charlton Wilbur Apr 9, 16:01
mlRe: ADC Core Data article ?????Andre? Apr 9, 18:08
mlRe: ADC Core Data article Scott Stevenson Apr 9, 18:24
mlRe: ADC Core Data article Scott Stevenson Apr 9, 18:27
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:06
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:16
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:38
mlRe: ADC Core Data article ?????Andre? Apr 10, 01:03
mlRe: ADC Core Data article Charlton Wilbur Apr 10, 01:13
mlRe: ADC Core Data article mmalcolm crawford Apr 10, 01:53
mlRe: ADC Core Data article Scott Stevenson Apr 10, 01:58
mlRe: ADC Core Data article Todd Blanchard Apr 10, 08:32
mlRe: ADC Core Data article mmalcolm crawford Apr 10, 08:52
mlModerator: EOT Re: ADC Core Data article mmalcolm crawford Apr 10, 09:25
mlRe: ADC Core Data article PA Apr 10, 12:08
mlRe: ADC Core Data article mmalcolm crawford Apr 30, 10:18