Code: Difference between a Library & Framework
Today I want to dive into the difference between a framework and a library. It’s one of those things where if you asked me “Hey, Andrea is a Library different to a a framework?” I would say “Yes! Of course..”, and then said person would be like “Oh! Okay..how so?” and I would have no way of answering the.
So, let’s figure this out together by breaking it down:
- Framework: By definition, “…provides a standard way to build and deploy applications” it is “..abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality..” (1). Okay…so far so good, right? Breaking this definition down and the way I see it — it an environment for functional code to be written and manipulated by the user.
- Library: According to Wikipedia, “is a collection of implementations of behavior, written in terms of a language, that has a well-defined interface by which the behavior is invoked” (2). Hmm okay let’s see — so from what I’m understanding a library is a set of packaged/compiled code with created with a specific functionalities that might want to be reused throughout the program.
A common misconception between libraries and frameworks are that — frameworks are simply a collection of libraries — Not necessarily true because not every Framework depends on libraries for full functionality(3). Let’s try and break down the relationship between the two / and see who calls who below:
- In a framework: the framework calls on your code
- In a library: it is your code that makes calls to the library
- The framework defines the control flow
Let’s better think a bit more about what makes a framework different than a library:
- Inversion of Control: Unlike libraries — in a framework, the programs flow of control is defined by the framework not by the caller (3). This is they key difference and defines how the to work together within an application.
- Extensibility: “user can extend the framework” (3) — by adding user code that has very specific functionality to the program.
- Strict framework specific code: As mentioned above — the user can extend the framework however the code of the framework is not meant to be modified (3).
- A library has methods and classes that are defined to execute and perform specific operations (4).
I hope breaking down this down helps. Although it all may still seem very fuzzy, I highly recommend watching this video: What is the difference between a framework and a library.
Thank you!! I highly accept an comments or inputs. :)
References:
- Software Frameworkhttps://en.wikipedia.org/wiki/Software_framework
- Library (computing)https://en.wikipedia.org/wiki/Library_(computing)
- SelectWhat Is the Difference Between a Framework and a Library?businessgeek — https://www.youtube.com/watch?v=D_MO9vIRBcA
- SelectLibrary Vs. Framework?https://www.programcreek.com/2011/09/what-is-the-difference-between-a-java-library-and-a-framework