What is the difference between a framework and a library?

后端 未结 19 1952
南旧
南旧 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

    I think that the main difference is that frameworks follow the "Hollywood principle", i.e. "don't call us, we'll call you."

    According to Martin Fowler:

    A library is essentially a set of functions that you can call, these days usually organized into classes. Each call does some work and returns control to the client.

    A framework embodies some abstract design, with more behavior built in. In order to use it you need to insert your behavior into various places in the framework either by subclassing or by plugging in your own classes. The framework's code then calls your code at these points.

提交回复
热议问题