[Dbix-class] Re: Reusing defined columns (inheritance?)
Darren Duncan
darren at darrenduncan.net
Sat Jan 4 09:10:44 GMT 2014
On 1/2/2014, 1:24 AM, Hartmaier Alexander wrote:
> On 2013-12-30 20:51, Dmitry Latin wrote:
>>> That's why frew wrote
>>> https://metacpan.org/pod/DBIx::Class::Helper::Row::SubClass.
>>>
>> Yeah, but it works only with one parent. I want to subclass from 2 parent
>> classes.
>>
>>
> Use roles instead of multiple-inheritance, much easier to get right!
I second that.
Generic columns such as eg creation date that have the same meaning in all the
tables they appear, eg this record was created then, conceptually this is a role
relationship not a subclass relationship.
A subclass relationship refers to things about which this statement is true:
"<subclass> is a <superclass>", whereas your example is more of a "<class> has
datestamped role.
Of course, conceptually the difference between class and role can blur
completely if you look at it from the perspective of each being a subtype of a
generic instantiable type where the definition of each is like "type foo is
subset of type object where has the columns {id, creation date, ...}" (this is
distinct from saying "has only the columns" but you can do that too). And
unlike some languages, it is trivially easy in Perl to implement types that way,
the generic instantiable type being a Perl hash say.
-- Darren Duncan
More information about the DBIx-Class
mailing list