Make effective use of the differences between libraries and frameworks

Tips and Tricks

Many developers loosely refer to jQuery as a "framework" or fail to understand the essential difference between it and bonafide JavaScript frameworks such as AngularJS and Bootstrap. Worse, by misunderstanding the difference, developers may miss the reasons to use frameworks or libraries. 

While both frameworks and libraries can help you enhance functionality and easily handle cross-browser issues, they differ in their overall design. Essentially, a library is a set of tools that your code can call, whereas a framework is something that calls your code. Implicit in the idea of a framework is a design concept called "inversion of control," sometimes known as the "Hollywood principle" ("don't call us, we'll call you"). 

While jQuery uses that principle in its frequent use of callback functions, true frameworks go further, leading you to structure your code into a certain architectural design pattern, such as Model-view-controller (MVC). 

A key reason to use a framework, then, is to organize your code so as to achieve certain best practices (such as separation of concerns), without having to reinvent the wheel to do so. For example, if you're starting a new project from scratch, you may want to consider how to avoid interspersing snippets of formatting-related code (strings of HTML or CSS) with business logic. If you use a framework, this problem is already largely solved for you. 

On the other hand, the advantage of using a library is that you can structure your code however you want and call only as much of it as you need. This makes libraries generally easier to learn and more suited to already-existing projects. Naturally, many projects use both frameworks and libraries, and some frameworks are built on top of libraries. 

To learn more, explore NH Phoenix training and certifications today!

Print
Author: Anonym
0 Comments

Theme picker

Loader

Contact author

x