Back to the subject of Immutability with domains. What occurred to me is that there is a difficulty in any domain relationship where Domain A has a reference to Domain B and Domain B holds a reference back to Domain A (where you don't want any duplication of objects). Due to any standard database loading or even object instantiation requiring either Domain A or Domain B to be created first, the first cannot get a reference to the second when created this way and if it is immutable then it cannot set the reference later. The only way I can think of that I think would work is if Domain A creates Domain B in its constructor passing a reference to itself and then assigning it to the final internal field. This makes the domain loading a bit tricky as it may require having some mutable objects or builders first and then using those to hold to data needed to create one Domain and the other in the first Domains constructor.
It made sense that this should work in my head last night as I lay awake unable to sleep with too much on my mind. I was tired though so I might have missed something. It might also be desirable to avoid having two way references like this as much as possible anyway. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
