Re: Can an entity be inherited from a value object?

Jim Amsden <[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <OFE2E65BD3.0E44E03A-ON85257C55.00083318-85257C55.00089EAF@us.ibm.com>
Probably not a good idea. Inheritance is suppose to follow the isA 
relationship - all instances of a subclass should also be instances of, 
and substitutable for, the superclass (but with additional information and 
behavior). An entity generally wouldn't be substitutable for a value 
object because it has identity, and expects to have identity-based 
relationships to other entities. So its often not practical to use 
call-by-value, or could be a bit unpredictable in terms of marshalling in 
a distributed environment without some thought about shallow/deep copy, 
transitive closure, etc. - things you generally don't need to worry about 
for a value object.

And then there's the issue of referential transparency which could be 
supported for value objects, but doesn't make sense for an entity. 

So although it would be possible for an entity to inherit the properties 
of a value object - it would probably be more appropriate for it to have a 
property whose type is the value object.


Jim Amsden, Senior Technical Staff Member
Solution Architect for Rational Government Industry Solutions
Make a new ULL Request
919-525-6575




From:   Fabrício Cabral <[email protected]>
To:     [email protected]
Date:   01/02/2014 07:57 PM
Subject:        [domaindrivendesign] Can an entity be inherited from a 
value object?
Sent by:        [email protected]





Hello everybody!

I have a conceptual doubt: can an entity be inherited from a value object?
For example, I have a class A which is a VO. So, can a class B which is
an entity extends this class A?

Could anyone give me a *real* example of this?

Thanks in advance.

-- 
--fx
(unnamed) (image/gif, 3.7 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.