Should entity have methods and if so how to prevent them from being called outside aggregate

前端 未结 2 1218
醉酒成梦
醉酒成梦 2021-01-22 14:13

So, if there is an entity within an aggregate what is the best/usual way to prevent outside world from doing something like Aggregate.Entity.SomeMethod()? (in case

2条回答
  •  清酒与你
    2021-01-22 14:48

    It is a question of visibility scope. It would depend on the programming language you are using. In java for example, I put an aggregate in a package. The aggregate root entity will be public. The others will have package scope, ie, no keyword for visibility.

提交回复
热议问题