views:

1082

answers:

9

I hear the whole day the terms class library, base class library, Framework, ...
What highlights a framework and what a base class library?

A: 

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

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

Daniel Earwicker
+1  A: 

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

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

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

Peter Wone
I see "base class library" a lot of times, right now in this book: ASP.NET 3.5 AJAX on page 126
Peter Gfader
+6  A: 

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

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

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

Smashery
+1 I like that example! I would say a framework allows you to visit a country. And you as a developer "decide" to visit France. A class library lets you then eat cheese, drink wine...
Peter Gfader
+4  A: 

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

Mork0075
+1 for "framework abstracts a whole class of problems"
Peter Gfader
+4  A: 

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

A framework is usually a recurring pattern/solution targeted towards a specific context e.g. a GUI Framework. A framework more than often implies that you write certain pieces as dictated by the framework designers, slot them in the expected/correct 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 contains multiple class libraries. As always, the terms are used in an ambiguous manner nowadays.. but the above represents the more common interpretation of the terms... mine atleast :)

Gishu
+1  A: 

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

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

Marc Gravell
+4  A: 

A Class Library is simply a set of classes encapsulated into a definable unit such as an assembly. The term is not restricted to any particular language or framework.

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

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

Cerebrus
+15  A: 

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

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

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

Jochen Walter
+1 for the link, it says it all :)
Binary Worrier
+3  A: 

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

Uday