在python中,构图和Facade是一回事吗?

2024-05-16 21:59:06 发布

您现在位置:Python中文网/ 问答频道 /正文

  1. 在python上下文中,合成和外观是相同的吗。我知道facade设计模式是用来做什么的,但是我只想确定我能调用实现facade的类,一个组合吗?

  2. 我能对mixin类说同样的话吗,还是说它只是一个不同的野兽,它们更接近于多重继承,并解决了facade之外的其他问题?

  3. 我们是否可以将Python中的composition松散地称为Java中的接口,或者这个语句完全不合适。

PS:我希望我的应用程序能够为客户提供一个标准接口,但是随着开发带宽的增加,在gut内部的具体实现将不断变化。由于客户机将使用这个类进行进一步的开发,所以我不希望他们的代码在我们对实现方面做任何更改时中断。在我开始这个项目之前,我想解决我的术语混乱。在


Tags: 应用程序客户机客户设计模式语句javafacademixin
1条回答
网友
1楼 · 发布于 2024-05-16 21:59:06

如上所述:

Composition is when one class contains members that are instances of other classes. The term Facade usually means that you are encapsulating a lot of logic behind the public members of a class. So notice that you can have composition without a Facade, if the composition members are all public. I won't get into the merit of a Facade without composition being valid, because that's a semantics labyrinth. BTW composition and interfaces are two different beasts, even if consider only Java or only Python.

相关问题 更多 >