tags:

views:

782

answers:

8
+4  Q: 

Framework Vs. API

Now, this may be a silly question but sometimes the terms Framework and API are used interchangeably. The way I see it is that a Framework is a bigger more generic thing, containing many API's, that could be used for various programming tasks (for example, the .NET Framework.) An API is smaller and more specialized (for example, the Facebook API.) Anyone want to share their insights on the matter?

And take for instance that Microsoft call .NET a Framework whereas Sun calls theirs a Platform ... so could it be also a business/marketing decision as to how call a "collection of libraries."?

+10  A: 

I've always thought the framework was the whole thing, internal code, API's, etc.

While the API is just the bit you use when you want to make use of the framework.

In other words, the .NET framework consists of the .NET libraries, all the languages and so on. The API is just the way you call the functions.

paxdiablo
+6  A: 

From my understanding, an API is basically a way of interfacing with an existing app (like Facebook), whereas a framework is basically a tool for building your own app from the ground up.

Mark
Yes, that's my point like a specialized interfacing... not necessarily an app could be hardware too.
jasonco
+1  A: 

I'd like to think that an API is a subset of a framework

Conrad
Yes, like a framework contains many API's. For example, the Java Platform provides the Java 2D API, which I've used to resize images.
jasonco
+3  A: 

As its name suggests (Application Programming Interface) the API is just the interface of the framework.

mouviciel
+1 Interface to the Framework, that's it
Peter Gfader
+2  A: 

In my experience, a framework often includes two things (at least) that an simple API doesn't:

  • Extensibility: you can compose or subclass framework components to extend or customize its functionality.

  • Tools for code-generation, administration, or diagnostic tasks related to application development.

Bill Karwin
I like this answer, thanks.
jasonco
Agreed - frameworks provide customisation, configuration and extension capabilities together with tools for code-generation, deployment and monitoring.
Gordon Mackie JoanMiro
+3  A: 

Design Patterns provide the following definitions:

  • toolkits: "often an application will incorporate classes from one or more libraries of predefined classes called toolkits. A toolikt is a set of related and reusable classes designed to provide useful, general-purpose functionality".
  • frameworks: "a framework is a set of cooperating classes that make up a reusable design for a specific class of software".

The key here is that while toolkits (APIs) can be useful in many domains, frameworks are geared to solve issues for specific classes of problems, that can be customized "by creating application specific subclasses of abstract classes of the framework".

Moreover, and maybe more importantly, "the framework dictates the architecture of your application": Inversion Of Control is one of the characteristics of frameworks (see Martin Fowler on this); instead of having your application call specific APIs to implement a specific behavior, it's the framework that calls your code.

Stefano Ricciardi
+5  A: 
VonC
+1  A: 
  • Software Framework: Is a re-usable design for a software system (or subsystem). A software framework may include programs, code libraries, a scripting language, other software to help develop and glue together the different components of a software project. Various parts of the framework maybe exposed through an API.

  • API (Application Programming Interface): Is a set of routines( AKA methods, functions), data structures, object classes, and/or protocols provided by libraries and/or operating system services in order to support the building of applications.
    More details along with other Link to this particular topic is http://aprogrammersday.blogspot.com/2009/02/difference-between-framework-and-api.html
Naeem Akram