Is circular reference between objects a bad practice?

后端 未结 3 917
情歌与酒
情歌与酒 2021-02-18 13:27

I have a Model that will \"carry\" (Model.validator) a validator instance with it, and I need the Validator to have access to the Model\'s attributes. So, what I have come up wi

3条回答
  •  灰色年华
    2021-02-18 13:45

    It will not be a problem for garbage collection: any new Garbage Collector (>IE6) will handle circular references just fine!

    It might be a problem though if you are doing recursive functions, or printing the object.

    So the answer is: it is no problem unless you screw up yourselves :-)

提交回复
热议问题