框架与.API [英] Framework Vs. API

查看:22
本文介绍了框架与.API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,这可能是一个愚蠢的问题,但有时框架和 API 这两个术语可以互换使用.我认为框架是一个更大更通用的东西,包含许多 API,可用于各种编程任务(例如,.NET Framework).API 更小,更专业(例如,Facebook API.)有人想分享他们对此事的见解吗?

Now, this may be a silly question but sometimes the terms Framework and API are used interchangeably. The way I see it is that a Framework is a bigger more generic thing, containing many API's, that could be used for various programming tasks (for example, the .NET Framework.) An API is smaller and more specialized (for example, the Facebook API.) Anyone want to share their insights on the matter?

例如,Microsoft 将 .NET 称为框架,而 Sun 将其称为平台……那么关于如何称为库集合"的业务/营销决策是否也是如此?

And take for instance that Microsoft call .NET a Framework whereas Sun calls theirs a Platform ... so could it be also a business/marketing decision as to how call a "collection of libraries."?

推荐答案

设计模式 提供以下定义:

  • 工具包:应用程序通常会合并来自一个或多个称为工具包的预定义类库中的类.工具包是一组相关且可重用的类,旨在提供有用的通用功能".
  • 框架:框架是一组协作类,它们构成特定软件类的可重用设计".

这里的关键是,虽然工具包 (API) 在许多领域都有用,但框架旨在解决特定类问题的问题,可以通过创建应用程序特定的子类来定制"框架的抽象类".

The key here is that while toolkits (APIs) can be useful in many domains, frameworks are geared to solve issues for specific classes of problems, that can be customized "by creating application specific subclasses of abstract classes of the framework".

此外,也许更重要的是,框架决定了应用程序的架构":控制反转是框架的特征之一(参见 Martin Fowler 对此);不是让您的应用程序调用特定的 API 来实现特定的行为,而是调用您的代码的框架.

Moreover, and maybe more importantly, "the framework dictates the architecture of your application": Inversion Of Control is one of the characteristics of frameworks (see Martin Fowler on this); instead of having your application call specific APIs to implement a specific behavior, it's the framework that calls your code.

这篇关于框架与.API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆