API、框架和中间件之间有什么区别?

发布于 2024-09-27 19:34:32 字数 1699 浏览 1 评论 0原文

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

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

发布评论

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

评论(5

月朦胧 2024-10-04 19:34:32

API 是应用程序程序员接口。它只是一个术语,指的是程序员与软件交互的方法。例如,DAO 可能有一个 save() 方法。 Save 是 DAO API 的一部分。在较高级别上,您可能具有“将用户添加到系统”功能。这是系统 API 的一部分。

框架是一个工具或一组工具。例如,Spring 是一个框架,可以管理控制反转、依赖注入,并提供漂亮的模板来让您的生活更轻松。您可以通过 Spring 的 API 使用 Spring。

中间件是允许一堆孤立的系统或功能进行交互的软件。因此,如果您有一个网站和一个支付系统,您可以使用中间件来连接。

An API is an Application Programmer Interface. Its just a term that refers to the methods a programmer will use to interface with the software. For example, a DAO might have a save() method. Save is part of the DAO API. At a high level, you might have an Add User to System functionality. Thats part of the system API.

A framework is a tool or set of tools. For example, Spring is a framework that manages your inversion of control, dependency injection, and provides nifty templates to make your life easier. You use Spring via its API.

Middleware is software that allows a bunch of isolated systems or functionalities to interact. So if you have a website, and a payment system, you use middleware to hookem up.

彩扇题诗 2024-10-04 19:34:32

API 是一个编程库(或多个库)的接口。它不会强加给你做任何事的方式。例如,OpenGL 并不限制您可以用它做什么。

框架为您提供部分完成的问题解决方案。你填补空白来制作你想要的东西。这可能会加速您正在做的事情,但您也会受到框架的限制,例如设计、性能、功能。 -- 例如,MFC 提供了一种创建 UI 的方法。它很好地支持对话框,但不支持表单,并且诸如对接之类的功能受到限制并且包含错​​误。 Windows 窗体是一个功能更强大的框架(来自 Borland Delphi 的架构师!),它在各个方面都更好:设计、灵活性、工具等。框架很棒,直到它们不做您希望它们做的事情,然后您您可能会失去大部分尝试解决这些问题所获得的时间。

中间件是一个垂直切片。如果您将软件视为分层的(例如操作系统、硬件抽象、实用程序库等),那么中间件垂直合并了许多这些层。它为您的应用程序中的某个区域提供完整或部分的解决方案。例如,代理消息传递系统或渲染库/引擎。中间件不仅提供基本库,还提供日志记录、调试和性能测量等相关工具。使用中间件时必须注意的一件事是DRY原则。由于中间件是垂直系统,它可能会竞争或重复应用程序的其他部分。

An API is an interface to a programming library (or libraries). It doesn't impose on you a way of doing anything. E.g. OpenGL doesn't restrict what you can do with it.

A framework supplies you with part finished solution to a problem. You fill in the blanks to make what you want. This might accelerate what you are doing, but you are also limited by the limitations of the framework, e.g. design, performance, functionality. -- E.g. MFC provided a way of creating UIs. It supported dialogs well, but not forms, and things like docking were limited and contained bugs. Windows Forms is a much more capable framework (from the architect of Borland Delphi!) which is better in every way: design, flexiblitiy, tools, etc. Frameworks are great until they don't do something you want them to do and then you may lose most of the time you gained trying to work around them.

Middleware is a vertical slice. If you think of software as layered (E.g. OS, hardware abstractions, utility libraries, etc), middleware incorporartes many of these layers vertically. It provides a full, or partial, solution to an area within your application. E.g. a brokered messaging system, or a rendering library/engine. Middleware supplies more than just the basic library, it also supplies associated tools like logging, debugging and performance measurement. One thing you have to be careful about when using middleware is the DRY principle. Because middleware is vertical system, it may compete or duplicate other parts of your application.

秋叶绚丽 2024-10-04 19:34:32

框架实现 API。 API 将框架客户端与底层框架的实现细节隔离开来。因此(从广义上讲)您可以使用 Mono 或 .Net Framework 来运行基于通用源代码的程序,因为这两个框架的 API 是相同的。

中间件通常是专门用于进程间通信的框架。

A framework implements an API. The API isolates framework clients from the implementation details of the underlying framework. Thus (broadly speaking) you can use Mono or .Net Framework to run a program based on common source code, because the API to either framework is the same.

Middleware is typically a framework specialized for interprocess communication.

〆一缕阳光ご 2024-10-04 19:34:32

API 是系统的编程接口。您使用它与系统交互,但不会强制程序中出现任何结构(理想情况下)。

框架规定了编写某些类型的应用程序的方式,以减少所需的样板数量。它解决了该类型应用程序的一些常见问题。

中间件主要是营销用语。有很多定义,但通常涉及一个大框架以及围绕它构建的一些工具。一些商业游戏引擎可以认为是中间件,SOA平台也被称为中间件等。

An API is a programatic interface to a system. You use it to interact with a system, but does not force any structure in your program (ideally).

A framework, dictates the way you write certain types of applications in order to reduce the amount of boilerplate needed. It solves some common problems for the applications of it's type.

Middleware is mostly marketing-speak. There are many definitions, but usually involve a big framework with some tooling built around it. Some commercial game engines can be thought of middleware, SOA platforms also are referred as middleware, etc.

飘然心甜 2024-10-04 19:34:32

主要区别在于功能的目的。

API旨在解决特定领域中的某些特定问题。它包含必要的数据结构、类、方法、接口等。
例如ADO.net API提供了连接Microsoft SQL Server的功能。

旨在帮助开发人员开发可重用、可扩展的软件应用程序的框架。框架没有像 API 那样的特定功能,而是通过 API 公开其各种功能。
例如,ADO.net是.net框架的一个API,用于访问数据服务。
一个框架有编译器、程序、类库、运行时。它可以添加插件。

The main difference is the purpose of functionality.

An API is designed to solve some specific problem in a particular domain.it contains necessary data structure, classes,methods,interface etc.
Such as ADO.net API provides the functionality to connecting Microsoft SQL Server.

A framework designed to help developer to reusable,scalable software application.a frameworks has no specific functionality like API but its various functionality exposed by API .
Such as , ADO.net is an API of .net framework for accessing data service.
A framework has compiler, programs,class libraries,run-time.it can add plug-in.

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