Composition Root

noun

say it: “kom-puh-ZISH-un ROOT” /ˌkɑmpəˈzɪʃən rut/

The one place, at the start of an app, where its parts are made and handed to whatever needs them.

What is a composition root?

A composition root is the one place, at the start of an app, where its parts are made and handed to whatever needs them. In the library's API it makes one database connection, one clock and the checkout service, and hands them out, so nothing else in the app says new for a service. A container is a composition root with a machine in it.

In a sentence

  • “When the database moved, we changed one line in the composition root and nothing else.”

Level: Journeyman · More OOP terms at this level

Updated