Original: http://www.programcreek.com/2011/09/what-is-the-difference-between-a-java-library-and-a-framework/
Both the original and the translation are only references, if not, please correct me.
What is the difference between a library and a framework? Both of these concepts are important, but sometimes they confuse Java developers.
1. Differences between libraries and frameworks and their respective definitions
Their main difference is in "control inversion". When you call a method from the library, control is on your hand. But when you use the framework, control is reversed, and the framework calls your code.
A library is just a collection of some class definitions. The idea behind this is simple code reuse, such as calling code that other developers have already written. These classes and methods are usually defined in a specific area of the specified operations, such as some mathematical operations library, developers do not have to re-implement the algorithm, directly call the inside of the method can be.
In the framework, all the control processes have been defined, and you just need to fill in some of the predefined blanks with your own code. The framework is more complex than the library, it defines the skeleton, and the application fills the skeleton with its own defined features. This way the framework will call your code at the right time, so the benefit is that the developer doesn't have to worry about the design, just implement the function of the specified domain.
2. Links to libraries and frameworks
They all need to define APIs that are easy for programmers to use. Connecting these, we can think of the library as a function of the program, the framework as a skeleton of the program, and the API is a connector that connects these. A typical development process begins with a framework, followed by a function in the implementation API.
Comparison of libraries and frameworks "translation"