简体   繁体   English

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

[英]What is the difference between an API , framework and middleware?

Just Randomly got this question in my head! 随便把这个问题放在我脑海里! Whats the difference between API , Framework and middleware? 什么是API,框架和中间件之间的区别? Essentially all of them provide abstract low level services to apps. 基本上所有这些都为应用程序提供了抽象的低级服务。 In that case why is dot net called framework and windows API called well.. API? 在那种情况下,为什么dot net称为框架和windows API称为.. API?

An API is an Application Programmer Interface. API是应用程序编程接口。 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. 例如,DAO可能有save()方法。 Save is part of the DAO API. Save是DAO API的一部分。 At a high level, you might have an Add User to System functionality. 在较高级别,您可能具有“添加用户到系统”功能。 Thats part of the system API. 这是系统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. 例如,Spring是一个框架,可以管理您的控制,依赖注入的反转,并提供漂亮的模板,让您的生活更轻松。 You use Spring via its API. 您可以通过其API使用Spring。

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. 因此,如果您有一个网站和一个支付系统,您可以使用中间件来启动。

An API is an interface to a programming library (or libraries). API编程库 (或多个库)的接口 It doesn't impose on you a way of doing anything. 它并没有强加给你一种做任何事情的方式。 Eg OpenGL doesn't restrict what you can do with it. 例如,OpenGL不限制你可以用它做什么。

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, eg design, performance, functionality. 这可能会加速您正在做的事情,但您也受到框架限制的限制,例如设计,性能和功能。 -- Eg MFC provided a way of creating UIs. - 例如,MFC提供了一种创建UI的方法。 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. Windows Forms是一个功能更强大的框架(来自Borland Delphi的架构师!),它在各方面都更好:设计,灵活,工具等。框架很棒,直到他们不做你想要他们做的事情然后你你可能会失去大多数时间试图解决它们的问题。

Middleware is a vertical slice . 中间件是一个垂直切片 If you think of software as layered (Eg 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. 它为您的应用程序中的某个区域提供完整或部分解决方案。 Eg 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. 使用中间件时必须注意的一件事是DRY原则。 Because middleware is vertical system, it may compete or duplicate other parts of your application. 由于中间件是垂直系统,它可能会竞争或复制应用程序的其他部分。

A framework implements an API. 框架实现API。 The API isolates framework clients from the implementation details of the underlying framework. API将框架客户端与底层框架的实现细节隔离开来。 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. 因此(广义上讲)您可以使用Mono或.Net Framework来运行基于公共源代码的程序,因为任一框架的API都是相同的。

Middleware is typically a framework specialized for interprocess communication. 中间件通常是专门用于进程间通信的框架。

An API is a programatic interface to a system. API是系统的程序接口。 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. 一些商业游戏引擎可以被认为是中间件,SOA平台也被称为中间件等。

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. API旨在解决特定域中的某些特定问题。它包含必要的数据结构,类,方法,接口等。例如ADO.net API提供连接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 . 一个旨在帮助开发人员使用可重用,可扩展的软件应用程序的框架。框架没有像API那样的特定功能,但是它暴露了API的各种功能。 Such as , ADO.net is an API of .net framework for accessing data service. 例如,ADO.net是.net框架的API,用于访问数据服务。 A framework has compiler, programs,class libraries,run-time.it can add plug-in. 一个框架有编译器,程序,类库,run-time.it可以添加插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM