Tuesday, March 2, 2010

Framework Vs Library

I was trying to understand the difference between Framework and a Library and came across an article by Martin Fowler on Inversion of Control. What I understand from that article is that the Inversion of Control is what makes a Framework different from a Library. I have in the past been involved in the development of reusable components, but wondered if they can be called as Frameworks, but the answer seem to be No, as in those cases, I have not inverted the control over to the Framework. So, those packages were just libraries and do not qualify to be called as Frameworks. What is the significant differentiator then? Based on my reading of various articles, I think the following are the key differentiators:

1. You call the a library method, whereas, a Framework calls your code.
2. A Library provides an API for your use, whereas a Framework provides an API to which your application should conform.
3. A Library is something contained within the application; i.e, if a library is not suitable, we can always substitute with a different library. But a Framework is a container for the application, having said that if the framework ends up not meeting the need, one need to throw away the entire application.

I also enjoyed reading the discussion on Why I hate Frameworks.

2 comments:

  1. Here is an interesting thought - do inheritance-composition opposition strongly resembles the framework-library distinction? Read this blog post and share your thoughts

    ReplyDelete
  2. Here is another interesting blog by Eric Bruno, titled as Are Application Frameworks Obsolete? Yes, I tend to agree with the author as organizatinos get it wrong while building the Framework.

    ReplyDelete