tags:

views:

122

answers:

4

From some browsing on net, I just understood that any framework is set of libraries provided by the framework and we can simply use those library functions to develop the application.

I would like to know more about

  1. what is a framework with respect to C++.
  2. How are C++ frameworks designed?
  3. How can we use them and develop applications.

Can someone provide me some links to understand the concept of "framework" in C++

+1  A: 

An application framework (regardless of language) is a library that attempts to provide a complete framework within which you plug in functionality for your specific application.

The idea is that things like web applications and GUI applications typically require quite a bit of boilerplate to get working at all. The application framework provides all that boilerplate code, and some sort of organization (typically some variation of model-view-controller) where you can plug in the logic specific to your particular application, and it handles most of the other stuff like automatically routing messages and such as needed.

Jerry Coffin
+2  A: 

More often than not, a framework (as opposed to "just" a library or set of libraries), in OOP languages (including C++), implies a software subsystem that, among other things, supplies classes you're supposed to inherit from, overriding certain methods to specialize the class's functionality for your application's needs, in your application code. If it was just some collection of functions and typedefs it should more properly be called a library, rather than a framework.

I hope this addresses your points 1 and 3. Regarding point 2, ideally, the designers of a framework have a lot of experience designing applications in a certain area, and they "distill" their experience and skill into a framework that lets (possibly less-experienced) developers build their own applications in that area more easily and expeditiously. In the real world, of course, such ideals are not always followed.

Alex Martelli
Thanks Alex, When it comes to using C++ framework, is it only that I need to inherit and override the functions for my application?
Teja
Alex, one more clarification please. Can we develop multiple applications with one framework?
Teja
@Teja, if in the course of time you need to develop multiple separate applications in the area a framework covers, of course you can use the same framework again. It's not necessarily as simple as "inherit and override" (for example, GUI frameworks often also require or at least strongly suggest the use of an associated GUI designer program to define the GUI's **looks**, while generally specific code is written just to define the **functionality** associated with given GUI events/actions) -- often the "inherit and override" is just _part_ of the whole job.
Alex Martelli
Thanks a lot Alex!!
Teja
+2  A: 
  1. A "framework" is something designed to provide the structure of a solution - much as the steel frame of a skyscraper gives it structure, but needs to be fleshed out with use-specific customisations. Both assume some particular problem space - whether it's multi-threaded client/server transactions, or a need for air-conditioned office space, and if your needs are substantively different - e.g. image manipulation or a government art gallery - then trying to use a poorly suited framework is often worse than using none. Indeed, if the evolving needs of your system pass beyond what the framework supports, you may find your options for customising the framework itself are insufficient, or the design you adopted to use it just doesn't suit the re-architected solution you later need. For example, a single-threaded framework encourages you to program in a non-threadsafe fashion, which may be a nightmare to make efficiently multi-threaded post-facto.

  2. They're designed by observing that a large number of programs require a similar solution architecture, and abstracting that into a canned solution framework with facilities for those app-specific customisations.

  3. How they're used depends on the problems they're trying to solve. A framework for transaction dispatch/handling will typically define a way to list IP ports to listen on, nominate functions to be called when connections are made and new data arrives, register timer events that call back to arbitrary functions. XML document, image manipulation, A.I. etc. frameworks would be totally different.... The whole idea is that they each provide a style of use that is simple and intuitive for the applications that might wish to use them.

A big hassle with many frameworks is that they assume ownership of the applications that use them, and relegate the application to a secondary role of filling in some callbacks. If the application needs to use several frameworks, or even one framework with some extra libraries doing e.g. asynchronous communications, then the frameworks may make that very difficult. A good framework is designed more like a set of libraries that the client can control, but need not be confined by. Good frameworks are rare.

Tony
Thanks Tony! From point 2, I understand that we can implement multiple applications using one framework? Am I correct?
Teja
@Teja: absolutely, that's the point of a framework - to make writing similar applications faster, easier, less error-prone, etc..
Tony
Thanks a lot Tony!!
Teja
+1  A: 

With a tool like CppDepend you can analyze any C++ framework, reverse engineer its design in a minute, but also have an accurate idea of the overall code quality of the framework.

Patrick Smacchia - NDepend dev