I learned a lot of things I didn't know during a job interview. Today I share with you the first one: Is there a difference between library and framework? Of course there is, but I didn't know it. For me they were the same.
The first thing that we have to know is both libraries and frameworks are pieces of code written by someone else that is used to help solve common problems and helps you to write your code faster and easier.
I think developers often use the terms “library” and “framework” interchangeably. There is a technical difference.
The technical difference between a framework and a library lies in a term called inversion of control. In other words, inversion of control defines the relationship between the code and a library or a framework.
Let’s use an example of baking a cake. You are the baker. So you have control over the baking process. You have a recipe and some of the ingredients, which represent your program. However, you need to go to the supermarket to buy the rest of the ingredients, which represents a library.
In this case, rather than baking the cake yourself, you go to a bakery to buy a cake. You get to choose the size, shape, and decorations, and the bakery will bake the cake for you according to your specifications. The bakery represents a framework and your customization represents your code.
A framework inverts the control of the program. It tells the developer what they need. A library doesn’t. The programmer calls the library where and when they need it.
So what do you think? Did you know the difference between these two words?
What else did you learn during a job interview ?
Top comments (2)
Simple and to the point thanks
Thank you !