在领域驱动设计中,工厂类可以访问基础设施吗?

发布于 12-24 20:28 字数 76 浏览 3 评论 0原文

如果有必要,工厂可以访问基础设施的元素来构建对象?在特定情况下,我有一个对象需要添加电子邮件签名,该签名作为参数存储在应用程序的配置层中。

If necessary, a factory can access elements of the infrastructure to build an object?. In a particular case, I have an object that I need to add email signature that is stored as a parameter in the configuration layer of the application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七分※倦醒2024-12-31 20:28:58

在 DDD 中,工厂与存储库处于相同的架构级别,但用于创建新对象而不是加载现有对象。因此它可以像存储库一样调用基础设施服务。

In DDD, a Factory is at the same architectural level as a Repository, but for creating new objects instead of loading existing objects. So it can call infrastructure services just like the repository.

挖个坑埋了你2024-12-31 20:28:58

这个问题没有一个正确的答案。如果工厂本身是应用程序层的一部分,那应该没问题。您还可以添加应用程序服务,在需要时将电子邮件签名传递到您的域中。

There is no one correct answer to this problem. If the factory itself is part of your application layer this should be fine. You can also add an application service that hands the email signature down into your domain when needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文