Re: How to avoid $class->new($value) with inflate

[prev] [thread] [next] [Date index for 2005/03/03]

From: Frank Carnovale
Subject: Re: How to avoid $class->new($value) with inflate
Date: 23:19 on 03 Mar 2005
I agree with you Ofer.

Our code has clumsy special cases that have to interrogate the has_a
rels to distinguish RDBMS-backed relationships from other clever OO
relationships.

In RDBMS theory we have the "domain" of a scalar column value (eg.
Date::Simple) and quite seperately we have relationships to other
entities in the model.    In OO theory we blend these two together.  The
theory's great but it sure would be convenient to distinguish the two
sometimes without having to say ref this and ref that to compare class
names.

frank

>>> Ofer Nave <onave@xxxxxxxxx.xxx> 04/03/05 4:39:46 AM >>>
Perrin Harkins wrote:

>On Thu, 2005-03-03 at 12:08 -0500, Michael Peters wrote:
>  
>
>>Perrin Harkins wrote:
>>
>>    
>>
>>>It's actually not a relationship.  It just maps database values to
and
>>>from local values.  It could even be done as a special accessor.
>>>      
>>>
>>But neither is the case where you use has_a to inflate a date into a

>>DateTime object.
>>    
>>
>
>Sure it is.  That's a relationship between your CDBI object and a
>DateTime object.
>
>- Perrin
>
>  
>
While it's convenient to have CDBI magically use relationships to 
inflate foreign keys into other CDBI objects, I question the wisdom of

piggybacking other forms of inflation upon the same mechanism.  I 
question even the wisdom of inflating CDBI objects using the current 
syntax, since many many people use blah_id as their foreign kay, and 
calling $obj->blah_id() to get the $blah object is nonsesnsical (and
the 
workarounds have problems, too).

It seems to me that the solution is seperating the relationship syntax

from the inflation/conversion/mapping/whatever syntax.  One set of 
methods to define relationships (which are *table relationships*, not 
the relationship between a datetime value and a datetime object) and 
another set of methods to inflate/deflate column values.

-ofer


                                       

(message missing)

How to avoid $class->new($value) with inflate
Matija Grabnar 12:18 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Charles Bailey 14:45 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
William McKee 15:17 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Matt S Trout 15:31 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
William McKee 15:40 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Charles Bailey 16:10 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Perrin Harkins 16:15 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
William McKee 16:50 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Perrin Harkins 17:00 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Charles Bailey 17:29 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Perrin Harkins 19:34 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
William Ross 17:10 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Michael Peters 17:08 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Perrin Harkins 17:12 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Perrin Harkins 19:49 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Carl Johnstone 09:56 on 04 Mar 2005

Re: How to avoid $class->new($value) with inflate
Frank Carnovale 23:19 on 03 Mar 2005

Re: How to avoid $class->new($value) with inflate
Frank Carnovale 23:44 on 06 Mar 2005

Re: How to avoid $class->new($value) with inflate
Matt S Trout 17:34 on 03 Mar 2005

Generated at 20:12 on 07 Mar 2005 by mariachi v0.52