Builder模式会取代工厂模式吗?

发布于 2024-07-30 17:45:26 字数 97 浏览 4 评论 0原文

我知道这个问题被问了很多次,但我只是想澄清更多。 建造者模式可以替代工厂模式吗?

是的,构建器模式逐步创建并返回一个复杂的对象,这也可以在工厂模式中完成。

I know this question is asked many times but I just want to clear more on this.
Can a builder pattern replace factory pattern.

Yes Builder pattern create and return a complex object step by step and this can be done in factory pattern also.

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

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

发布评论

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

评论(2

梦巷 2024-08-06 17:45:26

它们都是创造模式。 因此,不是替代,只是在某些情况下合适的替代方案。 模式的本质是它们为常见问题提供解决方案,细微不同的问题有不同的解决方案是很合理的。

所有讨论都在此处,如果您告诉我们您不理解或不同意此处答案的内容,也许会更有趣

They are both Creational patterns. So, not replace, just an alternative that's appropriate under some conditions. The nature of patterns is that they present solutions to common problems, it's quite reasonable that subtly different problems have different solutions.

All discussed here, maybe it's more interesting if you tell us what you didn't understand or agree with about the answers here

烟凡古楼 2024-08-06 17:45:26

有关何时使用构建器模式及其优点的更多信息,您应该查看我的帖子以了解另一个类似的问题这里

For more information on when to use the Builder Pattern and its advantages you should check out my post for another similar question here

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