[TYPO3-dev] Design Strategy Issue: Put ObjectStorage into Value Objects??!!

Christian Stüdemann typo3.v01 at christian-stuedemann.de
Fri Jan 2 01:01:00 CET 2015


Hi all,

I've got an immutable Value Object "Filter" describing a set of filter 
criteria and therefor storing lots of strings, booleans etc. Now I want 
to setup a filter for "categories", but these categories are part of my 
Repository, thus they are Entities and they are internally stored to an 
ObjectStorage.

If I would simply add "$categories" as a property to my "Filter" class, 
I would make the Value Object non-immutable, because it stores an 
ObjectStorage (mutable) with Category entities (mutable).

What kind of implementation would you recommend?

First ideas:

a) Clone the ObjectStorage to make it immutable inside the "Filter" 
class, but the entities are still mutable and cloning them wouldn't be a 
good idea, would it?! (Converting the ObjectStorage to an array of 
entities would be nearly the same.)

b) Store an array of UIDs to "Filter" instead of the actual entities and 
the ObjectStorage. This is easy to be made immutable, but it does not 
reflect the objects, thus I have to call the Repository each time I want 
to work with the objects.

c) ??!! Still thinking...

Any ideas?

Best regards,
Christian



More information about the TYPO3-dev mailing list