[TYPO3-mvc] Cloning properties in setter and getter methods of models (blog example)

Franz Koch typo3.RemoveForMessage at elements-net.de
Fri Feb 11 22:33:09 CET 2011


Hey Thomas,

>> So one can't simply fetch all Tags and add a new one to this
>> objectStorage which would be out of the scope of the domain models
>> responsibility (because maybe the setter from the domain model is
>> triggering some additional methods that depend on the setter etc).
>
> Hello Franz!
>
> That's a good point. So is there any recommendation what to use
> in general? Would it be "wrong" to not clone the objects?
>
> Probably it would be the best way to clone objects everytime
> in all getters and setters to ensure all is working properly, right?

no, not for all getters/setters - that would be a bad idea IMO. I'd 
probably only do it for getters/setters passing objectStorages if the 
model relies on the usage of special add/remove methods - but that's 
just my personal estimation - no recommendation. Until now I actually 
never passed cloned objects directly by setters/getters but after 
thinking about it might do so in future (for objectStorages and/or where 
appropriate).

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list