Library is like building your home from the ground up.
Framework, on the other hand, is like buying a new home.
What is a Framework?
It includes reusable pieces of code written to perform common tasks and uses code provided by a developer for custom functionality.
Why do we use Framwork?
Software frameworks make development easier by providing a common platform from which developers can control all or most of the software development process.
What is a Library?
It is essentially a set of pre-defined functions and classes that programmers can use to simplify their work and speed up the development process.
Standard libraries are available with most programming languages, but programmers can also make their own custom libraries.
Why do we need a library?
Since it’s more likely that other people are using it too, you’ll benefit from them finding and fixing any bugs. This is one of the reasons libraries are useful.
Key differences
Inversion of Control
By using a library, you control the flow of the program. The library can be invoked whenever and wherever you like.
Contrary to this, when you use a framework, the flow is controlled by the framework. The framework instructs you where to put your code, but it will call your code as required.
1) 일반적인 경우 : 객체가 필요하면 생성해서 쓴다.
2) IoC : 필요한 객체를 외부에서 만들어 주입해 준다. (객체를 교체하기 쉽다.)
1) 일반적인 경우 : 어떤 작업을 수행하기 위해 메서드를 호출한다.
2) IoC : 특정 상태에 놓일 때, 등록된 메서드가 자동 호출된다.
(리스너, 필터, 서블릿 등)