SOLID Flashcards
How do you spot DIP violations?
Does class depend on concrete objects?
Are you instantiating a concrete object in the constructor?
What technique does the DIP often use to fix issues?
Dependency injection
What is dependency injection?
In software engineering, dependency injection is a programming technique in which an object or function receives other objects or functions that it requires, as opposed to creating them internally.
What are the main benefits to the DIP?
Protect code by making it independent of elements that are fragile/unstable(concretions)
Components are loosely coupled (open to extention, closed for modification)
Testing is easy
What does it mean to depend on details
To depend on concrete objects. Owning an instance of a class
What are common problems associated with breaking the DIP?
Depending too much on concrete objects
How to we fix DIP violations?
We want to implement abstractions/interfaces in between classes that depend on concretions.