So as a Java developer we get to work with different frameworks and libraries. But have you ever wondered what makes a framework a framework? What is framework even means? And how is it different from a library?

Take something like Spring or Play Framework. What is it about them that makes them a framework and why do we even need frameworks?

Let’s find out:

Let me tell you a fundamental fact of a lifetime that’s applicable to us. Majority of enterprises java developers that are application working on very similar to this other application on which other developers are working on. Actually, that’s very similar to these 10 other applications that all of these other developers are working on.

But the actual matter is that there are a lot of enterprise business applications that you look not just in Java but in any platform. Yes, your domain may be very unique but it’s very likely that you are solving problems that are common to most other developers OK let me explain.

Your application needs authentication? And maybe it needs a large logger to when it needs to connect to a database. Maybe it’s a web application and you would need to respond to an HTTP request. These are not the main problems but that’s kind of fine. You need to add features code features to your application but these are common things that you will have to do anything no matter what the main application is doing and this is where we get some help from frameworks.

Maybe there is an open source project that you can bring in and it solves some of these problems. That’s cool because now all of those 100 java developers can use this open source project and application and get the benefits of that one common problem solved right? This is a model behind libraries.

Libraries exist and used to solve common problems and tasks that these multiple application developers are trying to solve. The goal is to help these common challenges so that developers can write codes and focus on the other problems that are actually trying to solve. Take for ex:- The log for a library that helps you with logging.

Libraries are reusable and how a well-defined API into a programming interface for ex:- they have certain classes, methods that you need to call to get the job done, these forms the interface of the library.

You can use it as many times as you want. The best technology that I can give is toolbox used by a carpenter. You didn’t actually make it yourself but then these are tools that you use when you need them.

The advantage of a library is that they can be used for a wide range of purposes. So let’s say you are building a table but then someone else is building a boat. They can use the same toolset that you used to built for the table and then apply it to boat building which is the completely different thing.

OK With that what is a framework?

Imagine a scenario where you have a bunch of people building a table like 100’s of carpenters all building table all the time. They have all specialized in tables. Now think that each of these carpenters when creating each of these tables go through pretty much a same set of steps. We have toolboxes to help the carpenters handle common tasks and they use it all these tools is repeated over and over, over the time.

So not only do you see common tasks and now you begin to see common patterns. So how do you make this easier? For Ex:- How about if you create a table manufacturing facility right! Take this example. Let’s say you have this machine where you drop in the wooden planks and its position is ready for the cut, attached to a machine for the saw and you get to cut it however you want. But the machine is there which lets you cut wooden planks and then machines puts these wooden planks into the iron machine with an attached hammer. It allows you to a position to nail the nails thus you have nailed the nails over there. How do you see what’s happening? You are streamlining the process that all carpenters would have to do anyway or you can say you have provided an overall framework for these carpenters to operate.

There is still freedom for the carpenters to saw the wooden in a different way or nail the nails using a different way.

But notice that the carpenters do not have full control over what they are building unlike using a library.

Carpenters have to control over whatever they want to build and they can use a library and they can use the library whenever they want with the framework. These carpenters are told exactly how things are going to go in general.

Frameworks provide patterns and they make it easy to operate with the consigns all those patterns.

In this java world, we have frameworks for building a web application and you can build any number of web applications for Ex; the framework says that I will listen to the web requests and handle the session and all that but when there is processing to be done I will come to you.

You call the library but you don’t call the framework. You supply the classes and methods and configure them to call your codes at right times.

On the one hand, makes things very simple but you lose the flexibility for ex:- you can use any library to build a web application you can use that library to build up own application anything else. But you can use a web application framework just to build web applications and you can’t use a web application framework to build a mobile application.

So which is good and which is bad? There isn’t a right or wrong answer. For instance, you are building an application with a framework will make your life simple and adaptive to the frameworks. We are doing things and lose some control.

So use library resource libraries or if you want to avoid libraries too and write a free line of Java code in your application yourself. It’s entirely up to you. Honestly but don’t go for the third option OK! It is ridiculous. Don’t do that. The first two options are OK.


Visit – Hostdens
$1 Unlimited Web Hosting Company


Vishwajit Kale

Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostdens, a company that aims to provide reliable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.