System Design
15. Software Design PatternsAnimated walkthrough
Dependency Injection
Pass dependencies in instead of creating them.
The idea
Objects receive collaborators from outside, making them easier to test and replace.
Watch it work
The steps light up one at a time. Use the controls to pause or step through.
- 1Declare what you need
- 2A container or caller provides it
- 3Use it
- 4Swap fakes in tests
1/4
Step by step
- 1Declare what you need
- 2A container or caller provides it
- 3Use it
- 4Swap fakes in tests
Where it is used
Testable code.
Watch out for
Heavy frameworks can hide wiring.