What is the difference between a framework and a library?

后端 未结 19 1932
南旧
南旧 2020-11-22 11:46

What is the difference between a framework and a library?

I always thought of a library as a set of objects and

相关标签:
19条回答
  • 2020-11-22 12:07

    Library:

    It is just a collection of routines (functional programming) or class definitions(object oriented programming). The reason behind is simply code reuse, i.e. get the code that has already been written by other developers. The classes or routines normally define specific operations in a domain specific area. For example, there are some libraries of mathematics which can let developer just call the function without redo the implementation of how an algorithm works.

    Framework:

    In framework, all the control flow is already there, and there are a bunch of predefined white spots that we should fill out with our code. A framework is normally more complex. It defines a skeleton where the application defines its own features to fill out the skeleton. In this way, your code will be called by the framework when appropriately. The benefit is that developers do not need to worry about if a design is good or not, but just about implementing domain specific functions.

    Library,Framework and your Code image representation:

    Library,Framework and your Code image relation

    KeyDifference:

    The key difference between a library and a framework is “Inversion of Control”. When you call a method from a library, you are in control. But with a framework, the control is inverted: the framework calls you. Source.

    Relation:

    Both of them defined API, which is used for programmers to use. To put those together, we can think of a library as a certain function of an application, a framework as the skeleton of the application, and an API is connector to put those together. A typical development process normally starts with a framework, and fill out functions defined in libraries through API.

    0 讨论(0)
  • 2020-11-22 12:08

    From Web developer perspective:

    1. Library can be easily replaceable by another library. But framework cannot.

      If you don't like jquery date picker library, you can replace with other date picker such as bootstrap date picker or pickadate.

      If you don't like AngularJS on which you built your product, you cannot just replace with any other frameworks. You have to rewrite your entire code base.

    2. Mostly library takes very less learning curve compared to Frameworks. Eg: underscore.js is a library, Ember.js is a framework.

    0 讨论(0)
  • 2020-11-22 12:09

    Library - Any set of classes or components that can be used as the client deems fit to accomplish a certain task.
    Framework - mandates certain guidelines for you to "plug-in" into something bigger than you. You merely provide the pieces specific to your application/requirements in a published-required manner, so that 'the framwework can make your life easy'

    0 讨论(0)
  • 2020-11-22 12:10

    This is how I think of it (and have seen rationalized by others):

    A library is something contained within your code. And a framework is a container for your application.

    0 讨论(0)
  • 2020-11-22 12:10

    here is linked a bitter article by Joel Spolsky, but contains a good distinction between toolboxes, libraries, frameworks and such

    0 讨论(0)
  • 2020-11-22 12:15

    A library implements functionality for a narrowly-scoped purpose whereas a framework tends to be a collection of libraries providing support for a wider range of features. For example, the library System.Drawing.dll handles drawing functionality, but is only one part of the overall .NET framework.

    0 讨论(0)
提交回复
热议问题