Home > Architecture, Programming > Frameworks vs. Libraries

Frameworks vs. Libraries

This post is part of a series of posts on Client-Side Web Application Development using JavaScript.

I have omitted JavaScript intentionally in the blog entry heading. This applies to other languages as well. Frameworks are opinionated. They enforce or provide some default architecture / structure to your application. Frameworks have inversion of control. That means frameworks may enforce a life-cycle and typically the framework calls your application code and not vice versa.

Libraries on the other hand or not opinionated. They solve a really specific problem and you can incorporate them in your application regardless of the architecture / structure of your application. Also your application code calls the library, so your application is in control.

Both the models have their pros and cons

Frameworks by enforcing some constraints / architecture absorb a lot of code into the framework itself, which otherwise has to be in the application.

Frameworks also standardize some of the decisions by taking them into the framework itself rather than leaving to the the parts of the application which can implement them in a different fashion.

Unfortunately at some junctures this high-handedness of the framework hurts us. When we need something in our application that the framework developer has not thought about or when we have to use the framework in an existing architecture / existing application.

Libraries shine when it comes to fitting them in an existing architecture / existing application. But that comes at the cost of having some of the infrastructure code in your application itself and fragmentized infrastructure code by having different implementations in different places (unintentionally).

So the key parameters here being

  • Is it a new application or is it an existing application?
  • If it is an existing application are the existing architecture / constraints compatible with the framework’s architecture constraints?
  • If it is new application are you comfortable with the decisions made by the framework / architecture / constraints enforced by it?
  • If it is a new application are all the requirements of the application aligned with the framework’s lifecycle / architecture / structure / constraints. If some are not does the framework allow the flexibility override those?

A sample classification in the JavaScript space via Steven Sanderson’s (Knockout’s author) blog.

Libraries Frameworks










Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: