Skip to content

Commit c12aeec

Browse files
authored
Added dependency inversion principle in SOLID (#32)
* add inversion of control principle * update Dependency Inversion Principle * Mistakes typo corrections * Added the acronym --------- Co-authored-by: luis.hincapie <luis.hincapie@blankfactor.com> Co-authored-by: luismateoh <luismateohm@gmail.com>
1 parent fac3b3c commit c12aeec

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ have any feedback or suggestions for improvement!
4949
- [Encapsulate What Changes](#encapsulate-what-changes)
5050
- [Interface Segregation Principle](#interface-segregation-principle)
5151
- [Command Query Separation](#command-query-separation)
52+
- [Dependency Inversion Principle](#dependency-inversion-principle)
5253
- [SOLID](#solid)
5354

5455
### Test
@@ -644,6 +645,42 @@ Resources
644645
- [Command Query Separation (wikipedia.org)](https://en.wikipedia.org/wiki/Command%E2%80%93query_separation)
645646
- [Command Query Separation (martinfowler.com)](https://martinfowler.com/bliki/CommandQuerySeparation.html)
646647

648+
## Dependency Inversion Principle
649+
650+
Dependency Inversion is the strategy of depending upon interfaces or abstract
651+
functions and classes rather than upon concrete functions and classes.
652+
Simply put, when components of our system have dependencies, we don’t want to
653+
directly inject a component’s dependency into another. Instead, we should use a
654+
level of abstraction between them.
655+
656+
**DIP** is the D in [SOLID](#solid).
657+
658+
Why
659+
660+
- By decoupling the high-level modules from the low-level modules, the
661+
high-level modules become more reusable and maintainable.
662+
- Facilitates unit testing by allowing the use of mock objects, enabling
663+
isolated testing of modules.
664+
- Reduces the risk of breaking the system when changes are made.
665+
- Allows adding new implementations without changing the existing code,
666+
enhancing the system's extensibility.
667+
- Concrete classes change frequently, while abstractions and interfaces change
668+
much less.
669+
670+
How
671+
672+
- Define interfaces to capture behavior and use them to define the dependencies
673+
of a class.
674+
- Depends on abstractions, not on concretions.
675+
- Using patterns like Factory, Service Locator, and Dependency Injection.
676+
- Use the [Inversion of Control](#inversion-of-control) principle.
677+
678+
Resources
679+
680+
- [SOLID — Dependency Inversion Principle](https://medium.com/@inzuael/solid-dependency-inversion-principle-part-5-f5bec43ab22e)
681+
- [Dependency inversion principle (wikipedia.org)](https://en.wikipedia.org/wiki/Dependency_inversion_principle)
682+
- [System Design: Dependency Inversion Principle](https://www.baeldung.com/cs/dip)
683+
647684
## SOLID
648685

649686
A subset of programming principles:
@@ -652,7 +689,7 @@ A subset of programming principles:
652689
- [Open/Closed Principle](#openclosed-principle)
653690
- [Liskov Substitution Principle](#liskov-substitution-principle)
654691
- [Interface Segregation Principle](#interface-segregation-principle)
655-
- Dependency Inversion Principle
692+
- [Dependency Inversion Principle](#Dependency-Inversion-Principle)
656693

657694
## FIRST principles of testing
658695

0 commit comments

Comments
 (0)