Difference Between a Framework and a Library
Frameworks and libraries are often used interchangeably, but they clearly have different meanings.
First, let’s look at what each term means.
Framework
A framework is literally a frame or skeleton. In program implementation, it determines the larger structure and controls the flow. Developers write code on top of it, and the framework runs the developer’s code according to that flow. Representative frameworks include the Spring framework and the .NET framework.
From “Framework Utilization Strategy”, Microsoftware, August 2006, p.130
Ralph Johnson, famous for the GoF design patterns, defined a framework as providing classes in a set of cooperative forms so that design and implementation corresponding to concrete parts of software can be reused. Unlike a library, a framework not only determines the application frame and structure, but also controls the developer’s code built on top of it. A framework has concrete and extensible base code and is composed of a set of design patterns intended by the designer.
Library
A library can be described as a collection or bundle of frequently used logic. Commonly used methods and functions are implemented in advance and added to a program for use. Developers can use prebuilt features conveniently and proceed with development quickly. Representative libraries include jQuery and Apache Commons Library.
Difference Between a Framework and a Library
The major difference between a framework and a library lies in who has control over the flow.
A framework controls the overall flow, and developers insert the necessary code within it. By contrast, with a library, developers create the overall flow and use the library as needed.
As an analogy, if a car is the framework, the wheels and steering wheel that belong to it can be considered libraries.
For this reason, replacing a library in an already implemented program may be relatively easy, but changing the framework shakes the entire foundation.
From Toby’s Spring 3, Chapter 1, Objects and Dependencies, p.95
A framework is a representative technology to which the concept of inversion of control is applied. A framework is not another name for a library. A framework is not simply a semi-finished product prepared in advance or a set of abstract libraries prepared for extension. To understand what a framework is, you must know how a library and a framework differ. Application code that uses a library directly controls the application flow. It only actively uses the library when necessary while it runs. By contrast, in a framework, application code is used by the framework. Usually, classes developed on top of a framework are registered, and while the framework drives the flow, it uses the application code created by the developer. Recently, toolkits, engines, and libraries are sometimes called frameworks just because the term is popular, but this is wrong. A framework must clearly apply the concept of inversion of control. Application code must operate passively within the structure arranged by the framework.
References
- http://webclub.tistory.com/458
- http://kwon37xi.egloos.com/2597583
- http://ohgyun.com/288
- http://hongsgo.egloos.com/809961
- http://www.zdnet.co.kr/news/news_view.asp?artice_id=00000039160910