Of Frameworks and Libraries

I was delivering a lecture on design patterns the other day. A student inquired whether design patterns were libraries. I had to spare some time to explain that this wasn’t the case. A library is a compiled code (of an application) that you can use in any program. By using I mean that you can call its objects, their functions, and properties in another program. This is a great utility of libraries. Consider that you have created an application that has a lot of functions to compute simple mathematical formulae. These could be anything like addition, multiplication, logarithmic, exponential or sinusoidal functions. One thing you can do is to compile it to create an executable program. The other thing you can do is to compile it to create a library. An example of the former is any executable program that a compiler creates. An example of the latter is a “jar” file created using the java compiler. Jar is an acronym for java archive(s). It is called an archive because it is a library that contains a compiled version of your application (your mathematics library).

You can use this jar file in many of your applications. You can even use it in different environments. For instance, both Matlab and octave maintain a java virtual machine when run. It means that you can run any executable program using either of these applications. Both of them also allow you to call java objects from third-party programs and applications. You can import your mathematical functions library we were talking about in the last paragraph and call its objects in Matlab and Octave. Eventually, you can utilize all of the publicly available functionality of its objects in these programs. Libraries are beneficial. For one thing, they save you from a lot of reinvention of the wheel.

What, then, are frameworks? This question has had me thinking intermittently during the past couple of days. I read in Timothy Budd’s lecture slides on object oriented programming that they are “shrinkwrapped” versions of code. What does this mean? An intuitive way to think about them for me was to imagine that frameworks enwrap huge programs that the programmer can use to get things done. This way of thinking about them has helped me, but I cannot explain this idea still very vividly. Another thing that was hinted at by Budd was that libraries address, and eventually allow you to access the objects from a very low level of abstraction. Frameworks, on the other hand, allow you to use programs and their objects from a very high level of abstraction. This further refines the thought process about frameworks and libraries. But I still have to find a better way to explain this. I shall keep on finding ways to sound more eloquent on this topic.

I read elsewhere on the web that you can use libraries and their objects and still keep control of the program that you are writing. Frameworks, on the other hand, take the control away from you. Similarly, another explanation was that the frameworks combine together a lot of applications and provide you a skeleton for a mammoth application. You fill in the code to connect the various parts of the skeleton together and get the code working.

In the interim, I would like to draw your attention to the following web resources to grasp a better understanding of these.

Library vs. Framework?

What is the difference between a Java Library and a framework? The two concepts are important but sometimes confusing for Java developers. 1. Key Difference

Photo by sk8geek

If you found an error, highlight it and press Shift + Enter or click here to inform us.

CC BY-NC-ND 4.0 Of Frameworks and Libraries by Psyops Prime is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Leave a Reply