Pages

What is the difference between a Library and a Framework?

Tuesday, November 12, 2013

It is quite a common question in all of the software developers mind, what is the difference between a Library and a Framework? The two concepts are important but sometimes confusing.

Key Difference and Definition of Library and Framework

The most important difference, and in fact the defining difference between a library and a framework is Inversion of Control(IoC). When you call a method in a library, you are in control. But with a framework, the control is inverted: the framework calls you. This is pretty much the difference and definition of a framework. In the framework, all the control flow is already there, and there’s just a bunch of predefined white spots that you should fill out with your code.

A library is just a collection of class definitions. The reason behind is simple, i.e. get the code that has already been written by other developers. The classes and methods normally define specific operations in a certain area. Your code is in charge and it calls into the library when it sees fit. E.g., jQuery.

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.

No comments:

Post a Comment