In the world of programming, the difference between Library vs Framework has always been a source of confusion and debate.
Many of us are unaware of the difference which is really important to understand during development.
Consider a simple example
When you are at your home, you can eat,sit,stand,do whatever activities wherever you like.
At home, there may exist some rules but its upto you whether to follow them and some or most of them are made by you.
But in your school/college/office you cannot do so.You have to follow some rules and always perform the activities in a specified manner.There can be some changes in workplace but upto a very little extent.You need to behave or work in a specified manner as expected.
“Who calls whom” i.e. the caller/callee relationship defines the difference between the two terms. It is our code which calls the library code.While in framework, it is the framework’s code which calls our code.
Whenever we have the power to call the code, that is simply a library.
The Framework calls our code and our code can call the library if needed.
Library
By definition - A library is a collection of related pieces of code that have been compiled and stored together in a single file. That file can be linked with your code to give you access to the code in the library.
Library provides a set of helper functions/modules/objects which is called by the application code for specific functionality.Library contains the code written by someone which is to be used by the application developer.
Code-Reuse. i.e get the code that is already written by other developers
Ex- jQuery, React
Framework
By definition - In general, a framework is a real or conceptual structure intended to serve as a support or guide for the building of something that expands the structure into something useful.
In computer systems, a framework is often a layered structure indicating what kind of programs can or should be built and how they would interrelate. Some computer system frameworks also include actual programs, specify programming interfaces, or offer programming tools for using the frameworks.
In a framework, all control flow is already there and thus, while using a framework, you have to adhere to some rules and restrictions while writing you code.
For example, in Spring, the definitions file is always to be named as 'ApplicationContext.xml'
and some directory structure is needed to be followed.
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.
The best way to identify a library or a framework is 'Who calls Whom'.
More links for reference
1. link-1

Better explanation .keep it up bro
ReplyDeleteGlad that It helps you.
Delete👍👍
ReplyDeleteNicely explain...well done akash
ReplyDelete