Home > Programming > A framework vs. a library.

A framework vs. a library.

Recently, we were discussing among the team if we are writing a library, a component or a framework? ๐Ÿ™‚ I remembered that I’ve seen a perfect (atleast for me) definition, which highlights the difference between two, out of the above three. And I vaguely remembered that it might be somewhere inside the Castle site, so after some searching, I stumbled upon the On Inversion of Control link, and voila, there it was –

The major difference between an object-oriented framework and a class library is that the framework calls the application code. Normally the application code calls the class library.

I don’t know if you like this definition or not, but it makes perfect sense to me ๐Ÿ™‚

Categories: Programming
  1. Rajasekaran Radhakrishnan
    November 13, 2008 at 2:12 am

    I visited this blog after a while and this one rang a bell. I quickly turned to the “Design Patterns” book where this runs between page# 26-28. In simple terms the difference is reusable code and reusable design.

    A library doesn’t impose a particular design on your application. It’s a collection of reusable code. Framework is a set of cooperating classes that make up the reusable design. It dictates the architecture of the application.

    By the way, the IoC definition (don’t call us, we’ll call you) under ‘Frameworks’ goes like “Reuse on this level leads to an inversion of control between the application and the ….When you use a framework, you … write the code it calls”.

  2. mmwaikar
    November 13, 2008 at 3:31 am

    Thanks for the comments Raj. I totally agree with the definitions (you mentioned) and now I’ve two very good points of differences between a framework and a library.

    So keeping the above definitions in mind, it’s obvious, that it’s very easy to write a library, but quite difficult to write a framework. And alas, uptil now, I’ve only written libraries ๐Ÿ˜ฆ I wish I write a framework someday…

    And if I am not wrong, “it”, in the sentence “When you use a framework, you โ€ฆ write the code it callsโ€ means the framework, right?

  3. Rajasekaran Radhakrishnan
    November 13, 2008 at 2:32 pm

    Yes Manoj, ‘it’ is framework.

    You know that when you are in a project since its conception, you most probably end up writing or using an existing framework since that’s when you identify things that will be repeated across the development lifecycle (MVC, business rules, data parsing/validations/formation, communication – DB, Remote Services etc). There is only one rule of thumb: try to use an existing framework.

    The difficulty in writing a framework comes from the fact that it involves careful design of interfaces it uses to call the application objects (and you can’t change the interfaces as you please:) ).

  4. mmwaikar
    November 14, 2008 at 3:44 am

    Super cool answer buddy, agree 100% with it. One of the guys whom I admire was criticizing Microsoft (MS) for making a few of it’s classes internal or sealed (final in Java), which limits extensibility. So one other guy, who wrote the Castle framework, and now has joined MS, replied that even he doesn’t like such decisions, but now he *somewhat* understands MS’s position because once they release an API or a framework, they just can’t change it just for the sake of backward compatibility.

    Thanks for your comments and please keep posting them ๐Ÿ™‚

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: