在包内部,我必须使用外观模式(或类似的东西)?

发布于 2024-11-09 20:47:52 字数 335 浏览 3 评论 0原文

我使用 Facade 来访问包内的方法和类,但是包内的方法和类呢?我必须直接或通过外观或类似的东西访问其他类的方法?

示例:Package 1(Class Foo, Class Bar, Facade FooBar)

外部类 -> FooBar--> Foo 方法

但内部:

Foo --> BarFoo --> FooBar-->酒吧Facade

I'm using a Facade to access the methods and classes inside package, but and inside the package? I must access the methods of other class directly or by a facade or something similar?

Example: Package 1(Class Foo, Class Bar, Facade FooBar)

Outside Class -> FooBar --> Foo method

but inside:

Foo --> Bar or Foo --> FooBar --> BarFacade

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

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

发布评论

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

评论(1

情独悲 2024-11-16 20:47:52

外观是一个单一的界面,可以轻松访问幕后发生的所有功能。它与将组件之间的内部功能从系统传回(并通过接口传回系统)的要求不同。

外观是控制面板,它们简化并隐藏内部组件,以便外部用户不会迷失在界面背后的复杂性中。具有内部组件的界面可以返回外部并通过界面操纵自身,这将是一个很好的艺术演示,但会是一个糟糕的外观,因为它会暴露它试图隐藏的东西。

Outside -> Facade -> Inside.

Outside -> Facade -> Inside -> Facade -> Inside.

或者在你的情况下

OutSide -> FooBar -> Foo -> Bar

就可以了。

A facade is a single interface which allows easy access to all the functionality going on behind the scenes. It is not the same thing as a requirement to pass internal functionality between components back out of the system (and back into it through the interface).

Facades are control panels, they simplify and hide the internal components so external users don't get lost in the complexity of what is behind the interface. An interface with internal components that reaches back outside and manipulates itself through the interface would make a good art presentation, but would be a lousy Facade, as it would expose that which is it trying to hide.

Outside -> Facade -> Inside.

not

Outside -> Facade -> Inside -> Facade -> Inside.

or in your case

OutSide -> FooBar -> Foo -> Bar

would be just fine.

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