在外观类之外创建一个对象,它会破坏外观模式吗?
在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于。如果
Room
属于您的环境(而不是隐藏在外观后面的另一个房间),那么这是一个合理的想法。如果 Room 属于其他上下文,那么您可能可以使用工厂或转换器从您系统中的原始属性或对象构建其他系统使用的对象。It depends. If
Room
belongs in your context (rather than the other one hidden behind facade), then it's a reasonable idea. IfRoom
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.