[ACCEPTED]-What is the difference between a class library and a framework-class-library

Accepted answer
Score: 22

The distinguishing feature between a class 7 library and a software framework is that 6 in a framework, the flow of control is not 5 determined by the user´s code, but by the 4 framework.

This is also known as Hollywood 3 principle (don´t call us, we call you).

By 2 the way, there is also a nice Wikipedia article on this 1 topic.

Score: 13

You use a class library in writing your 14 code, but you code within a framework.

The term 13 "framework" is meant to invoke a sense of 12 "being within an environment". If I were 11 to put a (limited) analogy to it, I'd say 10 that a class library is like being able 9 to eat cheese and drink wine, whereas a 8 framework is like visiting France; experiencing 7 the culture. The framework is the structure 6 around which you build your program. The 5 class library are the tools you use (possibly 4 within a framework).

Of course, a framework 3 will typically contain libraries of classes. .NET, for 2 instance, has heaps of class libraries which 1 are included in the entire framework.

Score: 9


It is just a collection of routines (functional programming) or 29 class definitions(object oriented programming). The reason 28 behind is simply code reuse, i.e. get the code that 27 has already been written by other developers. The 26 classes or routines normally define specific operations in a domain specific area. For 25 example, there are some libraries of mathematics 24 which can let developer just call the function 23 without redo the implementation of how an 22 algorithm works.


In framework, all the control flow is 21 already there, and there are a bunch of predefined white spots that we should fill out with our code. A framework 20 is normally more complex. It defines a skeleton where the application 19 defines its own features to fill out the 18 skeleton. In this way, your code will be 17 called by the framework when appropriately. The 16 benefit is that developers do not need to 15 worry about if a design is good or not, but 14 just about implementing domain specific 13 functions.

Library,Framework and your Code image representation:

Library,Framework and your Code image relation


The key difference between a 12 library and a framework is “Inversion of Control”. When you call 11 a method from a library, you are in control. But 10 with a framework, the control is inverted: the framework calls you. Source.


Both 9 of them defined API, which is used for programmers 8 to use. To put those together, we can think 7 of a library as a certain function of an 6 application, a framework as the skeleton 5 of the application, and an API is connector 4 to put those together. A typical development 3 process normally starts with a framework, and 2 fill out functions defined in libraries 1 through API.

Original answer

Score: 6

A class library usually is a DLL or a packet of classes 12 that you can "include"/"reference" into 11 your solution and reuse.

A framework is usually a 10 recurring pattern/solution targeted towards 9 a specific context e.g. a GUI Framework. A 8 framework more than often implies that you 7 write certain pieces as dictated by the 6 framework designers, slot them in the expected/correct 5 places and it should work.

  • e.g. Spring is a framework for DI. You write xml files in a format dictated by the designers and then the framework allows you to obtain assembled classes without having to worry about the framework does it.
  • Rails is a framework in Ruby for RAD web-apps. You only write the models, controllers and views and you have a working web app in under an hour.
  • the BCL is a set of class libraries so that you don't have to implement data structures and frequently used types in .NET and just get the tested proven implementations for free by just including them.

A framework usually 4 contains multiple class libraries. As always, the 3 terms are used in an ambiguous manner nowadays.. but 2 the above represents the more common interpretation 1 of the terms... mine atleast :)

Score: 5

Often you use libraries to get a certain 8 functionality in your OWN software/infrastructre. For 7 example printing a barcode, you would use 6 a library to do so. A framework abstracts 5 a whole class of problems, perhaps the problem 4 of writing web applications. To do so the 3 framework delivers the "frame" with all 2 functionality and stubs you can programm 1 against.

Score: 4

A class library is simply a set of classes 15 encapsulated into a definable unit such 14 as an assembly. The term is not restricted 13 to any particular language or framework.

The 12 Base Class Library (BCL) is a specific term attributes to 11 the set of class libaries that come pre-installed 10 with the .NET Framework which provide classes 9 neatly organized into namespaces so that 8 you have an API against which to build your 7 own solutions.

A framework is a wider term 6 that is inclusive of the class libraries, a 5 virtual machine that manages controlled 4 execution of processes, provides a runtime 3 environment, along with other services such 2 as memory management and exception handling. See 1 the .NET Framework for more information.

Score: 4

you call the code of class library where 1 as framework calls your code

Score: 2

I'd argue that the two are fairly interchangeable... - it 8 is simply a set of common re-usable code 7 (in whatever platform you are targetting), usually 6 supplied by the platform.

Maybe you could 5 argue that the BCL usually represents the 4 "pure" (vendor-independent) modules, where-as 3 the "framework" may (depending on how you use 2 the term) include the vendor's bespoke modules. But 1 that it perhaps open to local interpretation.

Score: 1

A framework is an allegedly cohesive collection 17 of one or more class libraries. The Java 16 and .NET frameworks, for example are made 15 up of hundreds of class libraries. In .NET 14 there is, by custom but not necessarily, a 13 correspondence between assemblies and class 12 libraries. In Java there is a rough correspondence 11 between namespaces and class libraries.

Although 10 I have never noticed the phrase "base class 9 library", I would expect such a thing to 8 contain abstract classes intended to be 7 subclassed before use.

Framework in the sense 6 of my first paragraph implies completeness 5 within the purview of the library. For example, you 4 would expect an image manipulation framework 3 to contain everything you need to manipulate 2 images, ranging from file format parsers 1 to in-memory graphics operations.

Score: 0

I think of a framework as a pattern that 11 an application can conform to, defined in 10 a set of libraries.

A "base" class library 9 might mean several things depending on the 8 context; it could refer to classes that 7 are designed to be derived from, which is 6 a common approach in frameworks, or it could 5 merely refer to a core library of classes 4 that are assumed to be useful in any application 3 and so are considered a "basic" need, almost 2 part of the language (for example, container 1 classes).

Score: 0

An application has many parts coexisting 25 in synchronization providing different functionality...now 24 code must be written for each of these parts 23 to work and therefore an Application Framework 22 does that code for you so that you don't 21 have to go through nitty-gritty of writing 20 every code related to every functionality.Application 19 frameworks make writing applications easier.

In 18 most simple terms if you are making a building 17 then its skeleton structure,Shape,functions 16 it can support,electrical and hydraulic 15 design , frames,etc are all its framework 14 and now you must work in that framework 13 to make your building so all the worrying 12 about making a earthquake proof structure 11 or making a linearly erect building has 10 been handled by your framework

It's that 9 simple. The framework takes all the complexities 8 of interfacing with the operating system 7 and simplifies them for you. It handles 6 all the nitty-gritty details for you. Obviously 5 certain frameworks do a better job at it 4 than others.

Difference between Application 3 Framework and Libraries : You use a class 2 library in writing your code, but you code 1 within a framework.

More Related questions