jargon

Comparison

Dependency inversionvsLayered architecture

Dependency inversion

the business rules import the Postgres driver, so testing a discount calculation needs a database.

Making the important code depend on an interface it defines, and the infrastructure depend on that interface too, so the arrow points inward instead of outward. The practical effect is that the rules of your business can be tested and understood without a network, a database or a cloud account. It is the backbone of the ports-and-adapters argument, and the reason a senior engineer will push back on a domain object that knows what a HTTP status code is.

Full entry →

Layered architecture

the controller called the database directly and three people commented on the pull request.

Arranging code so that each layer may only call the one beneath it — typically interface, application, domain, infrastructure. It gives you a rule that can be checked rather than an aesthetic, which is why layering violations are one of the few design arguments a linter can settle. Layers stop paying when they become pass-through: four layers that each rename a field are ceremony, not structure.

Full entry →

Related comparisons