边界类可以与实体类交互吗?
For instance: link
Is the above Ok or it would be better to create more methods in Controller that handle the data that are sent/retrieved without the interaction between UI and the Entity?
In general when is it allowed (if it is) for a Boundary Class to interact with an Entity Class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于您是否想要/需要严格遵守边界控制实体模式:
这并不意味着油嘴滑舌。这种严格的分离是否是良好的设计实践值得怀疑。它在图片中看起来很不错:边界、控制和实体位于漂亮的水平层中,消息仅传递相邻层。
现实却截然不同。严格分离可能会导致两个问题:
值得注意的是,在域驱动设计中,Eric Evans 建议仅当相关逻辑不存在时才创建服务(类似于控制器)。在任何域类(实体)中都没有可行的家。
Depends on whether you want/need to stick religiously to the Boundary-Control-Entity pattern:
That's not meant to be glib. It's questionable whether such strict separation is good design practice. It looks nice in pictures: Boundary, Control and Entity in nice horizontal layers with messages passing adjacent layers only.
The reality is rather different. Strict separation can lead to two problems:
It's notable that in Domain Driven Design, Eric Evans recommends creating Services (akin to Controllers) only when the logic in question doesn't have a viable home in any of the Domain Classes (Entities).