Repaso
EspaƱol
Design & PracticesFoundationsDP-58

Library vs framework: what is the key difference?

Options

  1. You call a library; a framework controls the flow and calls you (Correct option)
  2. They are exactly the same thing, with two different names
  3. A library is paid software and a framework is always free
  4. A framework is always smaller and simpler than a library

Answer

You call a library's code when you need it; a framework has the main flow and calls your code at points it defines (inversion of control)

Why

Martin Fowler describes a library as a set of functions that you call. A framework embodies an abstract design, and its code calls yours: 'Don't call us, we'll call you'.

Examples: requests and Jackson are libraries. Spring Boot and Django are frameworks.

MDN adds that a framework is a library that offers opinions about how software gets built.

Remember

Library: you call it. Framework: it calls you.

Key terms

Practice this question in Repaso