Critique of immutable classes with circular references design, and better options
问题 I have a factory class that creates objects with circular references. I'd like them to be immutable (in some sense of the word) too. So I use the following technique, using a closure of sorts: [<AbstractClass>] type Parent() = abstract Children : seq<Child> and Child(parent) = member __.Parent = parent module Factory = let makeParent() = let children = ResizeArray() let parent = { new Parent() with member __.Children = Seq.readonly children } [Child(parent); Child(parent); Child(parent)] |>