Best practice for adding a bidirectional relation in OO model

前端 未结 5 1459
無奈伤痛
無奈伤痛 2021-02-04 09:24

I\'m struggling to come up with a good way of adding a bidirectional relation in OO model. Let\'s say there is a Customer who can place many Orders, that is to say there is a on

5条回答
  •  春和景丽
    2021-02-04 09:43

    There is no single answer. It really depends on the classes involved. In your case, you obviously don't want to give people the option of doing something invalid so I would get rid of Order.SetCustomer.

    That may not always be the case though. Like I said, it depends on the classes involved.

提交回复
热议问题