wood burning stoves 2.0*
The moose likes Java in General and the fly likes Diff between a library and a Framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Diff between a library and a Framework" Watch "Diff between a library and a Framework" New topic
Author

Diff between a library and a Framework

Sudha Ugendran
Greenhorn

Joined: Oct 14, 2004
Posts: 9
What exactly is the differnce between a library and a framework?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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.


Groovy
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
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...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
Don't get me started about those stupid light bulbs.
 
subject: Diff between a library and a Framework