在外观类之外创建一个对象,它会破坏外观模式吗?

发布于 2024-09-08 01:28:40 字数 139 浏览 0 评论 0原文

在 HomeCADEngine 外观类中,我有一个方法“addRoom(room:Room)”,它将将此房间添加到 ArrayList 中。但是,当我们在 Facade 类外部创建一个房间,然后将其传递给 addRom() 方法时,是否会破坏 Facade 模式?

In HomeCADEngine facade class I have a method "addRoom(room:Room)" and it will add this room to a ArrayList. But is it break facade pattern when we create a room outside facade class and then pass it into addRom() method??

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

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

发布评论

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

评论(1

你没皮卡萌 2024-09-15 01:28:40

这取决于。如果 Room 属于您的环境(而不是隐藏在外观后面的另一个房间),那么这是一个合理的想法。如果 Room 属于其他上下文,那么您可能可以使用工厂或转换器从您系统中的原始属性或对象构建其他系统使用的对象。

It depends. If Room belongs in your context (rather than the other one hidden behind facade), then it's a reasonable idea. If Room belongs in the other context, then you probably could use a factory or translator which builds objects used by the other system from primitive properties or objects from your system.

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