I'm working through some stuff where I have a registry of services. Each service is put into the registry using a Put() method and stored as an object. I'd like that only the registry be able to modify the service objects. I have a GetService() method which returns the registered instance. I'd like that returned instance to be immutable (ie not change the values in my registry). I can (I suppose) return a clone of the registered object, but that becomes painful when the service has (a) collection(s) of child objects, which themselves may have children. Now I have to iterate all the way down, when I want to return a single instance. This seems ... painful.
I suppose I could be "smart" and use temp-tables to back the object properties (so just have the properties etc be a strongly-typed facade on temp-table fields) but this has it's own problems. Making individual objects immutable is easy enough ig you make all properties read-only and pass an entire object's definition via the constructor. I'm looking for "sometimes mutable" objects.
Just wondering what your (collective) thoughts on immutable objects (and how to implement in ABL cheaply/simply) in general, and on this topic are.
Maybe some helpful info can be found in redux docs f.e. redux.js.org/.../Reducers.html