Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 HomeCADEngine 外观类中,我有一个方法“addRoom(room:Room)”,它会将这个房间添加到 ArrayList。但是,当我们在外观类之外创建一个房间然后将其传递给 addRom() 方法时,它是否打破了外观模式?
这取决于。如果Room属于您的上下文(而不是隐藏在外观后面的另一个),那么这是一个合理的想法。如果Room属于其他上下文,那么您可能可以使用工厂或翻译器,它根据原始属性或系统中的对象构建其他系统使用的对象。
Room