DEV Community

Jessica-Agorye
Jessica-Agorye

Posted on

Inversion Control - The difference between a library and a framework.

In JavaScript web development, the term web frameworks and library come up ever so often. React for instance is often described as a framework and a library,there have been discussions on whether it's a library, a framework or both. However, understanding the difference between a framework and a library lies on a concept called "Inversion of Control" But first, lets define what we mean by framwork, and a library.

Library

JavaScript library is a collection of pre-written javascript code that provides reusable functions and features to help developers build web pages and applications more efficiently. These tools simplifies the
development process , and reduces the need to write certain code from
scratch.

Framework

JavaScript framework is an extensive package that contains HTML,CSS,JavaScript and other technologies. It offers predefined components and patterns that developers can use to write an entire application from scratch more efficiently , while also promoting consistent practices.

The key difference between a library and framework is "inversion control". What does this mean?

When using a library, the developer is in control, deciding how and when to use the library. The developer writes code that calls the library's functions to perform specific task.

When using a framework, the control is 'inverted'.This means the framework calls the developer's code during specific points in it's lifecycle. The framework detrmines the architectiure and flow of the application. In other words every code written by the developer must fit into the structure imposed by the framework.

Finir!

Top comments (0)