Daily iOS
Architecture

DI vs DIP

Dependency Injection and the Dependency Inversion Principle have similar names. What's the difference?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

DIP is a design principle: high-level policy depends on an abstraction, not a concrete type, and the concrete type implements that abstraction. DI is a technique: an object receives what it needs from outside instead of building it. DI is the usual way to realize DIP, but if you inject a concrete type, DIP is still broken.

Share a question