Dependency Injection
summary
Argues that Ruby benefits from explicit dependency injection contrary to common advice and ships a tiny DI framework built on the method_decorator gem that uses provides/requires annotations to auto-instantiate dependencies. Example builds a happy service that gets a weather service (which itself uses a location service), enabling unit tests by swapping in mock weather objects. It works for testability but trades clarity — dependencies appear magically — and requires each class to define initialize and extend a service provider.
AI-written summary · about
chapters (9)
- 0:00What is dependency injection
- 0:28HappyService
- 0:45Testing HappyService
- 1:00Testing WeatherService
- 1:22Dependency Injection
- 1:53Method Decorator
- 3:20Testing
- 3:43Disadvantages
- 4:15Outro
related talks
46mDependency injection is your friend
01h 29mDependency Injection in C++ - A Practical Guide
32mLet's Build a Dependency Injection Framework
54mDependency Injection revisited
40mFundamentals of Dependency Injection
31mBuild your own Dependency Injection framework!
49mReaders vs Constructors: Dependency Injection showdown
46mSlaying Sacred Cows: Deconstructing Dependency Injection
