What is a software framework? [closed]
Asked Answered
C

12

207

Can someone please explain me what a software framework is? Why do we need a framework? What does a framework do to make programming easier?

Cimah answered 3/6, 2010 at 7:55 Comment(0)
C
442

I'm very late to answer it. But, I would like to share one example, which I only thought of today. If I told you to cut a piece of paper with dimensions 5m by 5m, then surely you would do that. But suppose I ask you to cut 1000 pieces of paper of the same dimensions. In this case, you won't do the measuring 1000 times; obviously, you would make a frame of 5m by 5m, and then with the help of it you would be able to cut 1000 pieces of paper in less time. So, what you did was make a framework which would do a specific type of task. Instead of performing the same type of task again and again for the same type of applications, you create a framework having all those facilities together in one nice packet, hence providing the abstraction for your application and more importantly many applications.

Crifasi answered 4/10, 2012 at 18:5 Comment(10)
@NehaChoudhary, Not me, but he -1 because what you are talking about is a library, not a framework since there's no IoC.Claimant
Maybe This is not true , because we use definition above for a templateLeoine
@Leoine Templates, frameworks, semantics.Ineludible
I've read your post, but what you post sounds like what a library can do. How about explaining the difference between framework and library?Interpretative
I don't understand. From what you explained that would be more like a library right?Miscalculate
that's a wired explanation. What you explained is bare generic and doesn't fits in Software paradigm at all. Moreover, sole point your answer conveys is re-use which isn't enough for software framework. So, essentially you didn't answered about software framework rather about code libraries or BCL's which even C++ also has but C++ isn't a framework.Homologous
Very simple and easy to understand answer. After reading this answer, I remembered a scene (classroom where lead hero explains about machine) from an Indian movie "3 Idiots" :)Elenor
Found this explanation perfect for my friends that are not programmer while @aioobe's answer from wiki is best for techies.Steenbok
A framework is more like an automatic paper punch that accepts dies the user designs.Cadal
-1 Sorry, but this is actually a pretty good example of why people are so confused about terminology. A good sounding answer which is just wrong. I think you should try really hard to understand the description at en.wikipedia.org/wiki/Software_framework and then you should take this answer down, or seriously re-write it.Laughter
N
97

Technically, you don't need a framework. If you're making a really really simple site (think of the web back in 1992), you can just do it all with hard-coded HTML and some CSS.

And if you want to make a modern webapp, you don't actually need to use a framework for that, either.

You can instead choose to write all of the logic you need yourself, every time. You can write your own data-persistence/storage layer, or - if you're too busy - just write custom SQL for every single database access. You can write your own authentication and session handling layers. And your own template rending logic. And your own exception-handling logic. And your own security functions. And your own unit test framework to make sure it all works fine. And your own... [goes on for quite a long time]

Then again, if you do use a framework, you'll be able to benefit from the good, usually peer-reviewed and very well tested work of dozens if not hundreds of other developers, who may well be better than you. You'll get to build what you want rapidly, without having to spend time building or worrying too much about the infrastructure items listed above.

You can get more done in less time, and know that the framework code you're using or extending is very likely to be done better than you doing it all yourself.

And the cost of this? Investing some time learning the framework. But - as virtually every web dev out there will attest - it's definitely worth the time spent learning to get massive (really, massive) benefits from using whatever framework you choose.

Nardone answered 3/6, 2010 at 8:7 Comment(8)
Why not put that energy into contributing to an open-source framework, rather than lashing up your own stuff? 'Alone, we can move rocks; together we can move mountains' and all thatNardone
@Jefffrey "Then how will you learn? How will you grow up as a programmer?" Learn however you want, but if you intend to work for a real client, you should provide the best possible solution in the shortest amount of time. YOUR "probably buggy" code isn't acceptable for that.Danieldaniela
@Cmorales, if you want to learn a programming language or any domain specific problem you are surely not going to have any "real" client (and you'll possibly have a lot of time in your hand) and that is why I suggest newbies not to start from frameworks.Orola
@Jefffrey You didn't say anything about newbies in your comment, it was general. I agree that you should learn on your own first, but your comment didn't specify that and in real (work) life you can't afford using buggy code just to learn. I know some guys who don't use frameworks because they think they know better... and expend twice the time for each project.Danieldaniela
@Danieldaniela I also know some people who do use frameworks but also take twice the time for each project. Programming speed isn't always related to the tools being used.Sodality
@Sodality It is if you say a project took you 6 months because "they asked for complicated things, such as pretty URLs", which is something even the crappiest framework does for you out of the box. My point was that those guys were slow because they re-invent the wheel.Danieldaniela
@Danieldaniela Strawman argument. Using a framework does not make you fast. Not using a framework does not make you slow.Sodality
@Sodality Not a strawman argument, I was talking about a real case. A friend of mine knows a lot, but he once lost a job because he refused to work with a framework with that exact complain about pretty URLs. Anyway, my original point was about using buggy code "to learn", not about speed. That was just a related comment, regarding some (stubborn) guys I know.Danieldaniela
F
58

The summary at Wikipedia (Software Framework) (first google hit btw) explains it quite well:

A software framework, in computer programming, is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality. Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined Application programming interface (API), yet they contain some key distinguishing features that separate them from normal libraries.

Software frameworks have these distinguishing features that separate them from libraries or normal user applications:

  1. inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.[1]
  2. default behavior - A framework has a default behavior. This default behavior must actually be some useful behavior and not a series of no-ops.
  3. extensibility - A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.
  4. non-modifiable framework code - The framework code, in general, is not allowed to be modified. Users can extend the framework, but not modify its code.

You may "need" it because it may provide you with a great shortcut when developing applications, since it contains lots of already written and tested functionality. The reason is quite similar to the reason we use software libraries.

Forefoot answered 3/6, 2010 at 8:0 Comment(3)
the white part of your answer was way more better than the grey part, according to the type of question...Fanchet
I am pretty sure the person asking the question found the Wikipedia entry too... He/She probably looked for a more comprehensive answer.Irritate
OOP -- I think that to really understand this, requires that you have looked at something like Templates in c++ or the like. Without that you won't really understand what is hinted at by terms like "selective overriding", or "specialized".Laughter
F
32

A lot of good answers already, but let me see if I can give you another viewpoint.

Simplifying things by quite a bit, you can view a framework as an application that is complete except for the actual functionality. You plug in the functionality and PRESTO! you have an application.

Consider, say, a GUI framework. The framework contains everything you need to make an application. Indeed you can often trivially make a minimal application with very few lines of source that does absolutely nothing -- but it does give you window management, sub-window management, menus, button bars, etc. That's the framework side of things. By adding your application functionality and "plugging it in" to the right places in the framework you turn this empty app that does nothing more than window management, etc. into a real, full-blown application.

There are similar types of frameworks for web apps, for server-side apps, etc. In each case the framework provides the bulk of the tedious, repetitive code (hopefully) while you provide the actual problem domain functionality. (This is the ideal. In reality, of course, the success of the framework is highly variable.)

I stress again that this is the simplified view of what a framework is. I'm not using scary terms like "Inversion of Control" and the like although most frameworks have such scary concepts built-in. Since you're a beginner, I thought I'd spare you the jargon and go with an easy simile.

Forthwith answered 4/6, 2010 at 11:38 Comment(0)
D
15

I'm not sure there's a clear-cut definition of "framework". Sometimes a large set of libraries is called a framework, but I think the typical use of the word is closer to the definition aioobe brought.

This very nice article sums up the difference between just a set of libraries and a framework:

A framework can be defined as a set of libraries that say “Don’t call us, we’ll call you.”

How does a framework help you? Because instead of writing something from scratch, you basically just extend a given, working application. You get a lot of productivity this way - sometimes the resulting application can be far more elaborate than you could have done on your own in the same time frame - but you usually trade in a lot of flexibility.

Delft answered 3/6, 2010 at 9:13 Comment(0)
C
8

A simple explanation is: A framework is a scaffold that you can you build applications around.

A framework generally provides some base functionality which you can use and extend to make more complex applications from, there are frameworks for all sorts of things. Microsofts MVC framework is a good example of this. It provides everything you need to get off the ground building website using the MVC pattern, it handles web requests, routes and the like. All you have to do is implement "Controllers" and provide "Views" which are two constructs defined by the MVC framework. The MVC framework then handles calling your controllers and rendering your views.

Perhaps not the best wording but I hope it helps

Cleveite answered 3/6, 2010 at 8:35 Comment(1)
Actually, it's more like building applications into the scaffolding than around it.Marcelline
B
6

at the lowest level, a framework is an environment, where you are given a set of tools to work with

this tools come in the form of libraries, configuration files, etc.

this so-called "environment" provides you with the basic setup (error reportings, log files, language settings, etc)...which can be modified,extended and built upon.

People actually do not need frameworks, it's just a matter of wanting to save time, and others just a matter of personal preferences.

People will justify that with a framework, you don't have to code from scratch. But those are just people confusing libraries with frameworks.

I'm not being biased here, I am actually using a framework right now.

Bloch answered 3/6, 2010 at 9:0 Comment(0)
P
4

In General, A frame Work is real or Conceptual structure of intended to serve as a support or Guide for the building some thing that expands the structure into something useful...

Peoria answered 30/3, 2013 at 8:55 Comment(0)
F
2

A framework has some functions that you may need. you maybe need some sort of arrays that have inbuilt sorting mechanisms. Or maybe you need a window where you want to place some controls, all that you can find in a framework. it's a kind of WORK that spans a FRAME around your own work.

EDIT: OK I m about to dig what you guys were trying to tell me ;) you perhaps havent noticed the information between the lines "WORK that spans a FRAME around ..." before this is getting fallen deeper n deeper. I try to give a floor to it hoping you're gracfully:
a good explanation to the question "Difference between a Library and a Framework" I found here
http://ifacethoughts.net/2007/06/04/difference-between-a-library-and-a-framework/

Fanchet answered 3/6, 2010 at 7:57 Comment(4)
totally do not understand the down votes... I am completely stunned about it. the question is the sort of beginner basic question and my answer was according to that fairly good...Fanchet
To be clear: I didn't down vote. However what you are talking about is on a much lower level than what a framework is concerned about. Collections and Sorting Algorithms are more of standard libraries than Frameworks for example.Mosely
thanks for the answer but ... it's not the answer to my question. according to the quesion of OP, dinstinguishing between "standard library" and "framework" is the wrong place here. e.g. in the .net-framework you can find the namespace collections in a part of the framework I have never heard anybody saying the namespace collecsion is not part of the .netframework. so your answer to my question is wrongFanchet
This is the definition of a library. It misses the distinguishing trait of a framework as opposed to a library: Inversion of Control.Marcelline
T
2

A framework provides functionalities/solution to the particular problem area.
Definition from wiki:

A software framework, in computer programming, is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality. Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined Application programming interface (API), yet they contain some key distinguishing features that separate them from normal libraries.

Tantara answered 3/6, 2010 at 8:8 Comment(1)
There is a word in first sentence "abstraction". what do you mean by that ? where do we use abstraction?Turkestan
B
2

A framework helps us about using the "already created", a metaphore can be like,

think that earth material is the programming language,

and for example "a camera" is the program, and you decided to create a notebook. You don't need to recreate the camera everytime, you just use the earth framework (for example to a technology store) take the camera and integrate it to your notebook.

Banebrudge answered 3/6, 2010 at 8:15 Comment(0)
J
2

Beyond definitions, which are sometimes understandable only if you already understand, an example helped me.

I think I got a glimmer of understanding when loooking at sorting a list in .Net; an example of a framework providing a functionality that's tailored by user code providing specific functionality. Take List.Sort(IComparer). The sort algorithm, which resides in the .Net framework in the Sort method, needs to do a series of compares; does object A come before or after object B? But Sort itself has no clue how to do the compare; only the type being sorted knows that. You couldn't write a comparison sort algorithm that can be reused by many users and anticipate all the various types you'd be called upon to sort. You've got to leave that bit of work up to the user itself. So here, sort, aka the framework, calls back to a method in the user code, the type being sorted so it can do the compare. (Or a delegate can be used; same point.)

Did I get this right?

Junina answered 13/9, 2010 at 22:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.