Today's Question:  What's your opinion about Alibaba mooncake incident?        GIVE A SHOUT

Technical Article => Programming =>  Java

Java API vs Framework      2011-12-19 13:40:33      4,830    0    0

What is the difference between a Java Library and a framework? The two concepts are essentially important for a Java developer.

The most important difference between a library and a framework is Inversion of Control. It means that when you call a library you are in control. But with a framework, the control is inverted: the framework calls you. (This is called the Hollywood Principle: Don’t call Us, We’ll call You.)

This is pretty much the definition of a framework. Basically, all the control flow is already in the framework, and there’s just a bunch of predefined white spots that you can fill out with your code.

A library is a collection of class definitions. The reason behind is simple, i.e. get the code that has already been written by other developers. The classes and methods normally define specific operations in a certain area. For example, there are some libraries of mathematics which can let developer just call the function without redo the implementation of how an algorithm works.

A framework is normally more complex. It is a skeleton where the application defines the “meat” of the operation by filling out the skeleton. The skeleton has code to link up the parts(e.g. define work flow), but the different requirements implementation is done by the application. The benefit is that programmers do not need to worry about if a design is good or not, but just about implementing domain specific functions.

Their relation?

Both of them defined API, which is used for programmers to use.

To put those together, we can think of a library as a certain function of an application, a framework as the skeleton of the application, and an API is connector to put those together.

A typical development process normally start with a framework, and fill out functions defined in libraries through API.

Source :



Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious



No comment for this article.


We are Twins

By sonic0002
This scene happens at the Roxbury theme one night back in 90's. The original video can be found at YouTube.