1.6 What Is a Framework?

I have been using the term framework in this chapter without having defined what exactly it is, or how it adds value in software development. In its simplest form, a framework is a set of classes and interfaces that cooperate to solve a specific type of software problem. A framework has the following characteristics:

·         A framework comprises multiple classes or components, each of which may provide an abstraction of some particular concept.

·         The framework defines how these abstractions work together to solve a problem.

·         Framework components are reusable.

·         A framework organizes patterns at a higher level.

A good framework should provide generic behavior that many different types of applications can make use of.

There are many interpretations of what constitutes a framework. Some might consider the classes and interfaces provided by the Java language a framework, but these are really a library. There's a subtle, but very important, difference between a software library and a framework. A software library contains functions or routines that your application can invoke. A framework, on the other hand, provides generic, cooperative components that your application extends to provide a particular set of functions. The places where the framework can be extended are known as extension points. A framework commonly is referred to as an "upside-down" library because of the alternate manner in which it operates. Figure 1-5 illustrates the subtle differences between frameworks and software libraries.

Figure 1-5. A framework and a library are not the same thing

figs/jstr_0105.gif