質問

  1. In the python context, are compositions and facades the same things. I know what facade design pattern is used for, but just wanted to make sure can I call my class, which implements a facade, a composition?

  2. Can I say the same for a mixin class as well, or is it just a different beast all together having more proximity to multiple inheritance and solving some other problem than facade?

  3. Can we loosely call composition in Python equivalent to interfaces in Java, or this statement is totally out of place.

PS: I want my application to provide a standard interface to clients but the exact implementation, inside the gut, will keep changing overtime as we get more development bandwidth. Since the client will use this class for further development I don't want their code to break in case we make any change on the implementation side. I want to fix my jargon confusions before I start the project.

役に立ちましたか?

解決

As noted above:

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top