I have a scenario wherein I have associated a collection of Model object against an identifier[BASE]. As per my business use case I can create a scenario from the identifier[BASE]. In that case the collection on model object is also referred to. Doing so I dont need to create snapshots of same data again.
Another use case is that user might modify some value in the derived scenario from identifier[BASE]. In this case, Model object corresponding to the modified value will be replaced with new Model object.
This scenario might happen as many times wherein my whole collection of Model objects might be replaced by new objects.
My question is that the approach of creating a new immutable object and replacing it in the reference everytime user modeifies anything is appropriate or not.
Or could there be another better approach, wherein whenever user modifies the object instead of returning a new immutable object we should return a new mutable object which can further be mutated as many times as required by user. This would also ensure that the initial collection of Model objects is not mutated.
Any thoughts.
TIA!