Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diff between a library and a Framework

 
Sudha Ugendran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is the differnce between a library and a framework?
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Library is a set of utility classes which most of the time could be used directly.

Framework is a set of classes which you would extend. Framework provide the implementaion of reprtitive tasks. For example Struts is a MVC framework and your application will extend those classes.

Others opinion may vary.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Library is a set of utility classes which most of the time could be used directly.

Framework is a set of classes which you would extend. Framework provide the implementaion of reprtitive tasks. For example Struts is a MVC framework and your application will extend those classes.

Others opinion may vary.


Pradeep, I guess Sudha is talking about the frameworks like Collections framework... Not kind of Struts Frameworks...

In the case of Collections framework, the framework is very similar to the library... I guess he might want to get a clear explanation on it... In this case, I don't know how to explain it well, we know that we call it Collections framework and don't call it Collections library... I guess it's kinda of naming stuff...
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One (not the only) definition of frameworks is that they provide some basic functionality and invite you to plug in your application-specific customizations. You might register a listener for some framework-generated events or extend an abstract framework class and override some "developer hook" methods. Or both.

For example, the SAX parser for XML does all the hard work of parsing tags and attributes and such and invites you to provide a handler for certain interesting bits. That fits the framework definition. For my own use, I made an abstract handler that I extend and override a few methods for specific XML structures. We could call that single handler class a framework, too.

One thing you see in this style is a reversal of control. Without a framework your code has to do everything and controls the sequence and logic directly. In contrast, a framework takes on some of the control and just calls your code at appropriate times.

FYI:
My SAX Handler
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic