Briefle
LearnGlossaryPricing

Briefle words · Code & architecture

Dependency injection

Passing a component the things it depends on from outside, instead of letting it create them itself, so they can be swapped, for example in tests.

Say it to an AI

Python RefundService using dependency injection: pass the PaymentGateway and a clock callable into the constructor instead of creating Paylane or calling datetime.now() inside, so tests can use a fake gateway and a fixed time. Raise RefundWindowClosed past the deadline.

How an expert would brief the stronger version of “Refund service”.

See it

Try it as a puzzle →

A fintech backend refunds card payments, but only within the refund window.

Study A · the stronger one
Study B · the weaker one

Why: A's '__init__(self, payments, clock=datetime.now)' receives both; B's '__init__' creates 'PaylaneGateway(...)' on its own.

Related words

  • Single responsibility principle
  • Flag argument
  • Side effect
  • Parameter object
  • Long parameter list
  • Named arguments
  • Options object
  • Utils file

Room 3 · Functions & structure

Learn “Dependency injection” in a five-minute lesson

Start free
AI can build almost anything. The bottleneck is saying what you want.
WordsPricingTermsPrivacyRefundsContact
© 2026 Briefle