[FLOW3-general] How to use value objects
lukas lentner
kontakt at lukaslentner.de
Thu Feb 24 09:22:32 CET 2011
Hi Guys,
I understand that VO have no setters and get their values through constructing. But why leads
$this->date = $this->objectManager->create('F3\FamilyNetwork\Domain\Model\Value\Date');
$this->location = $this->objectManager->create('F3\FamilyNetwork\Domain\Model\Value\Location');
to just one object (Date). After Persistence saved the objects, when they are read back from the database, an error occurs which says the $this->location has the wrong type (Date) but should have "Location".
It seems FLOW3 uses in the second line above the Date-object from the first line! But how can FLOW3 say a NULL-Date (no values) is the same as a NULL-Location (no values) - it's not! Please use also the class to determine if an VO is there already - not just the data, because sometimes 2 different objects have both no values but are still not identical!
Thankx
Lukas
-----Ursprüngliche Nachricht-----
Von: robert at typo3.org [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von Robert Lemke
Gesendet: Mittwoch, 23. Februar 2011 09:13
An: General discussion about FLOW3
Betreff: Re: [FLOW3-general] How to use value objects
Hi Lukas,
Am 22.02.2011 um 08:21 schrieb Martin Kutschker:
> Am 08.02.2011 19:33, schrieb lukas lentner:
>>
>> 3. Why do I need to give every value object an constructor?
>
> I don't know if there are technical reasons, but as value objects should be immutable they will have
> usually no setters.
yes, correct. A value object without a value doesn't make sense. But because a value object must be immutable, we force you to use a constructor for passing the values. If that's a problem in real life we need to discuss this, but we thought that it makes sense.
Cheers,
Robert
_______________________________________________
FLOW3-general mailing list
FLOW3-general at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list