[DISCUSSION] Object Relational Mapping (ORM) for different programming languages

Philip Mötteli philip.moetteli at econophone.ch
Wed Oct 10 15:54:19 CDT 2007


Am 10.10.2007 um 18:26 schrieb Ruslan Zasukhin:

> On 10/10/07 12:48 PM, "Philip Mötteli" <philip.moetteli at econophone.ch>
> wrote:
>
>>> ----------------------------------------------------
>>> DECLARATION:
>>>
>>>     class Contact < ActiveRecord::Base
>>>        belongs_to :state
>>>     end
>>>
>>> USAGE:
>>>
>>>    Contact.find(1).state.abbreviation
>>> ----------------------------------------------------
>>>
>>>
>>> And this raise question if possible get such or similar syntax for
>>> REALbasic
>>> or C++ or other languages that Valentina supports.
>>>
>>> And as far as I see answer is NO.
>>>
>>> BECAUSE it seems to me Ruby allow return some kind of general
>>> parent Object
>>> class and send him any messages, i.e. Calls of methods.
>>>
>>> C++ and REALbasic are strict type languages. You cannot take
>>> REALobject and
>>> calls method of its sub-class.
>>>
>>> May be such style possible in Obj-C.
>>
>> Yes, it is.
>> The first part though, where he declares the relationship, has to be
>> implemented in a OR-library, so that it is reflected in the db.
>
> Or even better on db engine level, right?

(Disclaimer: I don't know Ruby and I don't know RealBasic either.)

Actually, as far as I understand it, Valentina is much better than  
this approach. As I understand it, this ActiveRecord library has to  
create a foreign key at the other side. With Valentina, we can just  
use OID and it's done. Especially, we have the huge advantage, that  
this OID can point to any table.
For the other part: what is great with dynamic, dynamic (method)  
binding, is that I can put a fault at the place of the real object  
(containing only this OID) and when this fault receives any message,  
the fault replaces itself with the real object, by loading the data  
from the db, and then forwarding the original message to the real  
object. We say, that the fault has fired.
I don't even need a common superclass, like this ActiveRecord.
Even, if you don't have something like OID, one could replace that  
with two entries for each of those relationships:

1. the name of the other table. (-> kind of TABLE_ID)
2. the primary key of the record. (-> kind of REC_ID)

Less handy, than Valentina.


Re
Phil



More information about the Valentina mailing list