A framework is like Ikea furniture, you take it, build something with it, and you have a nice looking thing that is standard, and there are many flavors of the same thing to choose from. But just because you can built a shelf with Ikea's out of the box shelf solutions, doesn't mean you could actually build a nice shelf all by yourself. If you truly understood the principles of carpentry, then you could go to home depot, buy the required items, and make a shelf yourself. Now then, you might think that you don't need to be able to build it from scratch as you can still furnish a room with Ikea furniture. That's true in many cases but what if a client then comes back and says "I like this shelf but I wish it also had LED lighting on the edges." or something silly? You might not know how to make that work. Or someone comes to you, knowing you work with shelfs and needs you to fix theirs. If you can't build one, you won't be able to make a nice solution. You may fix it, but it will not look good and be harder next time(I.E Tech debt). So understanding the framework is very useful.
The library on the other hand, is a small standardized piece of that shelf. Its not a full solution, just a small part, but makes things a bit easier. Maybe home depot in the example above sells the inner pieces of wood that you actually set things on, cut in a standard size that you need, all lacquered and ready to go. Or perhaps the little plastic things you set the shelves on so you can move them and adjust their height instead of using L-brackets. They aren't a full solution, but enough of them fit together to make a framework.
In the end, the basic idea is that "a framework calls your code, you call a library's code" is the measuring stick I've heard and it seems to be true more or less.
BONUS SHELF ROUND:
The L-brackets vs the little plastic shelf stoppers are a good example of dependency injection. The actual shelf doesn't care how you've decided to implement a stopper for it to rest on, just that you have something, these are interchangeable and not coupled with the shelf at all. The same way a class wouldn't care which implementation of a dependency you give it, just that it's given one.
Love your explanation! And the bonus. :D
Love your explanation! 😃
It is easy to understand when it is explained with real examples.
So much furniture to assemble...#Ikeaproblems
Might try and re-work the comment into its own post later. I'm sure if I put a bit more effort into it I could make the idea I'm trying to convey a bit easier to understand. :)
Glad it worked out well for you though!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.