框架、工具包和库之间的区别是什么?


当前回答

库只是将方法/函数打包到一个包中的集合,可以导入到代码项目中并重用。

A framework is a robust library or collection of libraries that provides a "foundation" for your code. A framework follows the Inversion of Control pattern. For example, the .NET framework is a large collection of cohesive libraries in which you build your application on top of. You can argue there isn't a big difference between a framework and a library, but when people say "framework" it typically implies a larger, more robust suite of libraries which will play an integral part of an application.

我认为工具包和SDK是一样的。它附带文档、示例、库、包装器等。同样,您可以说这与框架是相同的,您可能这样做是正确的。

它们几乎都可以互换使用。

其他回答

图书馆

我认为库是已经编码的代码,您可以使用它,从而不必再次编码,这是一致的。代码的组织方式必须允许您查找所需的功能并从自己的代码中使用它。

大多数编程语言都带有标准库,特别是一些实现某种集合的代码。这是为了方便您不必自己编写这些代码。类似地,大多数编程语言都有构造,允许您从库中查找功能,例如动态链接、名称空间等。

因此,发现自己经常需要重用的代码是放入库中的好代码。

工具包

工具:用于特定目的的一套工具这是一致的。问题是,什么被认为是工具,什么不是。我想说没有固定的定义,它取决于自称为工具包的东西的上下文。工具的例子可以是库、小部件、脚本、程序、编辑器、文档、服务器、调试器等。

另一个需要注意的是“特殊目的”。这总是正确的,但是目的的范围很容易根据工具包的制作者而改变。所以它可以是程序员的工具箱,也可以是字符串解析工具箱。一个是如此广泛,它可以有工具触及所有编程相关的,而另一个是更精确。

sdk通常是工具包,因为它们尝试将一组工具(通常是多种类型的)捆绑到一个包中。

我认为常见的思路是,工具为您做了一些事情,要么是完全的,要么是帮助您做这些事情。工具箱只是一组工具,它们都执行或帮助您执行一组特定的活动。

框架

框架的定义并不一致。对于任何可以构建代码框架的东西,这似乎是一个通用术语。这意味着:任何构建或支持代码的结构。

这意味着您根据框架构建代码,而根据代码构建库。

But, it seems that sometimes the word framework is used in the same sense as toolkit or even library. The .Net Framework is mostly a toolkit, because it's composed of the FCL which is a library, and the CLR, which is a virtual machine. So you would consider it a toolkit to C# development on Windows. Mono being a toolkit for C# development on Linux. Yet they called it a framework. It makes sense to think of it this way too, since it kinds of frame your code, but a frame should more support and hold things together, then do any kind of work, so my opinion is this is not the way you should use the word.

我认为这个行业正试图将框架转变为一个已经编写好的程序,其中缺少你必须提供或定制的部分。我认为这是一件好事,因为工具箱和库是“框架”其他用法的非常精确的术语。

库和框架之间最重要的区别,实际上是定义性的区别是控制反转。

这是什么意思?好吧,这意味着当你打电话给图书馆时,你是在控制。但是对于框架,控件是反向的:框架调用您。(这就是所谓的好莱坞原则:不要给我们打电话,我们会给你打电话。)这就是框架的定义。如果它没有控制反转,它就不是一个框架。(我在看你,.NET!)

基本上,所有的控制流都已经在框架中,只有一堆预定义的白点,您可以用您的代码填写。

另一方面,库是您可以调用的功能的集合。

I don't know if the term toolkit is really well defined. Just the word "kit" seems to suggest some kind of modularity, i.e. a set of independent libraries that you can pick and choose from. What, then, makes a toolkit different from just a bunch of independent libraries? Integration: if you just have a bunch of independent libraries, there is no guarantee that they will work well together, whereas the libraries in a toolkit have been designed to work well together – you just don't have to use all of them.

但这只是我对这个术语的解释。与定义良好的库和框架不同,我不认为工具包有一个被广泛接受的定义。

库只是将方法/函数打包到一个包中的集合,可以导入到代码项目中并重用。

A framework is a robust library or collection of libraries that provides a "foundation" for your code. A framework follows the Inversion of Control pattern. For example, the .NET framework is a large collection of cohesive libraries in which you build your application on top of. You can argue there isn't a big difference between a framework and a library, but when people say "framework" it typically implies a larger, more robust suite of libraries which will play an integral part of an application.

我认为工具包和SDK是一样的。它附带文档、示例、库、包装器等。同样,您可以说这与框架是相同的,您可能这样做是正确的。

它们几乎都可以互换使用。

框架:安装在你的机器上,允许你与它交互。没有这个框架,你就不能向你的机器发送编程命令

库:旨在解决某一问题(或同一类别的若干问题)

工具包:许多代码片段的集合,可以在多个问题上解决多个问题(就像工具箱一样)

关于Mittag的正确答案:

一个简单的例子。假设您在一个类中实现了ISerializable接口(. net)。你利用了。net的框架特性,而不是库特性。你填上“白点”(就像mittag说的),你就完成了骨架。你必须事先知道框架将如何“反应”你的代码。实际上。net是一个框架,这就是我不同意Mittag观点的地方。

你的问题的完整的答案在本书的第19章(整个章节都是关于这个主题的)中给出了,顺便说一下,这是一本非常好的书(完全不是“只是为了Smalltalk”)。