Frameworks vs Libraries According to Cats and Dogs

dotbehrens

dotbehrens

Posted on October 7, 2019

Frameworks vs Libraries According to Cats and Dogs

There is much contention in the programming world over what is the difference between a framework and a library. Many use the terms interchangeably, however they are two different tools for accomplishing tasks. A library is a file that holds commonly used functions in order to cut down on code repetition. Common libraries include Underscore, JQuerey and React.

A framework, on the other hand, provides the structure for app development. Common frameworks include Mocha, .Net and Angular. Libraries and frameworks can be used in conjunction, it all depends on what is the right tool for the job.
Libraries are loosely structured and so they can be sprinkled throughout the code without any real issues. Frameworks are more difficult to implement as the project goes on, so it is best to begin a project with the framework you will require.

Alt Text

The above graphic illustrates how frameworks and libraries work in regards to the application being built. With a framework the application resides in its framework. The framework is the barrier that keeps the application in line. Libraries function with the application working side by side to accomplish the task.

The main difference between frameworks and libraries lies in the inversion of control. With a library, the programmer is in control of how the library is used and implemented. When using a framework the framework is in control of how things are used and implemented inside of it. I like to think of frameworks and libraries as cats and dogs. Both are good pets. Some projects are cat projects, some projects are dog projects and some projects have happily coexisting dogs and cats. The distinct behavioral differences in the two differences have the same inversion of control as frameworks and libraries.

Think of a library as a well-trained dog. It will come when you call it, sit when told to, and will do anything to it can to please its owner.

Alt Text

A cat, on the other hand, is more like a framework. A cat is more likely to tell you when they want you to come and sit than it is to listen to your commands. They may graciously agree to use the litter box but I have never seen a cat do anything it doesn't want to do.

Alt Text

Frameworks and libraries can be described in the terms opinionated and opinionated. Typically frameworks are more opinionated whereas libraries are opinionated. Much like cats and dogs, they don’t all fit the same mold. There may be a framework that is okay with giving the programmer more freedom and control, as there are cats who are more submissive than others.
An example of an opinionated framework is Angular and an example of an unopinionated framework is Backbone. There are libraries that may be more opinionated than others, much like my dogs who very much tell me when to eat, sleep, and rub their bellies(are my dogs cats?).

Alt Text

In conclusion, the best way I have to remember the difference between frameworks and libraries is to think of cute little animal faces, and who really has control in the relationship.
Alt Text

💖 💪 🙅 🚩
dotbehrens
dotbehrens

Posted on October 7, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related