DEV Community

Partha Maity
Partha Maity

Posted on

Library vs Framework Explained

Library

You started a project and finished it and then started an other one and noticed ๐Ÿคจ that you have repeated some pieces of code from previous project and then you finished it.

Next day, you started a new project and damn! you noticed it again, you once again repeated some pieces of code from previous two projects.

Hmmm!! ๐Ÿค” ...

So you thought - "Why not I copy those repeating pieces of code and keep it in a separate file, so that the next time I need it, I can just copy it from there."

That's how the concept of library came into existence.

A library is a collection of reusable pieces of code that can be used in multiple projects.


Framework

Once fine day, you started a project and you noticed that you have to repeat some pieces of code from previous projects. You grabbed your library and copied those pieces of code and probably felt happy ๐Ÿ˜„ that you have saved some time.

But soon that happiness turned into frustration ๐Ÿ˜ค when you received handful of bugs ๐Ÿ› from the application. You started debugging and realized that you have to fix the same bug in multiple places ๐Ÿ˜ซ. You fixed it and moved on.

For the next few days, you kept on receiving bugs ๐Ÿ› and fixing them.

....and then one day, you realized that if you had followed a particular structure or pattern, you would have saved yourself from all these bugs ๐Ÿ›. You made few rules from your experience and started following them.

You noticed that you were able to fix bugs ๐Ÿ› faster and also were able to add new features faster. It just boosted tour productivity of building applications.

You just created your own framework.

A framework is a collection of rules and guidelines or a structure for building an application.


Note: The above explanation is just for understanding purpose. It is not a complete explanation of library and framework. If you find any mistake in the above explanation, please let me know. I will be happy to correct it.

Top comments (0)