插件和框架的区别

发布于 2024-10-29 09:23:59 字数 35 浏览 0 评论 0原文

框架和插件有什么区别?即哪些因素决定何时使用插件和框架?

What is the difference between frameworks and plug-ins? i.e Which factors decide when to use plug-ins and frameworks?

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

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

发布评论

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

评论(1

银河中√捞星星 2024-11-05 09:23:59

框架提供功能,必须编写程序才能使用这些功能;插件扩展了其他东西的功能,通常不需要重写现有程序即可使用。您可以很好地使用两者,通过提供基本界面的框架和向界面添加功能的插件。

例如:

  • PAM

    PAM 库是一个框架; PAM 模块是插件。您可以编辑 /etc/pam.conf/etc/pam.d/* 来使用插件,而不是重新编译使用 PAM 库的代码。但是旧的包需要重写以使用PAM框架,而不是直接访问各种系统文件。

  • NSS

    类似地,NSS 由一个框架和一组在该框架内提供功能的插件组成。在这种情况下,大多数东西不需要重新编译,因为旧框架(libcgetpwent和类似函数)提供的接口对于新框架来说已经足够了一。 (例外是依赖影子密码文件的任何东西,或者对于更旧的程序,依赖常规密码文件中的密码。)配置涉及编辑 /etc/nsswitch.conf 而不是修改程序。 p>

  • 赛勒斯SASL

    与上面类似,SASL库是一个框架,但身份验证机制是插件。配置主要是通过 SASL lib 目录中的文件进行的,尽管某些程序也使用一个接口,允许将其嵌入到这些程序自己的配置文件中;同样,无论哪种情况,都不需要重新编译来添加、更改、启用或禁用机制。

  • 在 Mac OS X 上,服务是作为插件实现的;相应的框架内置于标准框架中。

Windows 有类似的框架和插件,但我对 Windows 的了解还不够,无法指出任何好的例子。

无论如何,一般规则是使用框架为程序提供访问功能的接口,并使用框架内的插件来提供或扩展其功能。

Frameworks provide functionality, which programs must be written to use; plugins extend something else's functionality, usually in a way that doesn't require rewriting existing programs to use. You may well use both, with a framework that provides a basic interface and plugins that add functionality to the interface.

Examples of this are:

  • PAM

    The PAM library is a framework; PAM modules are plugins. You edit /etc/pam.conf or /etc/pam.d/* to use the plugins, instead of recompiling code that uses the PAM library. But older packages need to be rewritten to use the PAM framework instead of directly accessing various system files.

  • NSS

    Similarly, NSS consists of a framework and a set of plugins that provide functionality within that framework. In this case, most things don't need to be recompiled because the interfaces provided by an older framework (libc's getpwent and similar functions) were mostly sufficient for the new one. (The exception being anything that relied on the shadow password file, or for even older programs the password in the regular password file.) Configuration involves editing /etc/nsswitch.conf insyead of modifying programs.

  • Cyrus SASL

    Similar to the above, the SASL library is a framework, but the authentication mechanisms are plugins. Configuration is mostly by files in the SASL lib directory, although there is also an interface used by some programs which allows it to be embedded in those programs' own configuration files; again, in either case it doesn't require recompiling to add, change, enable or disable mechanisms.

  • On Mac OS X, services are implemented as plugins; the corresponding framework is built into the standard frameworks.

There are similar frameworks and plugins for Windows, but I don't really know enough about Windows to point to any good examples.

In any case, the general rule is that you use a framework to provide interfaces for programs to access functionality, and use plugins within a framework to provide or extend its functionality.

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