Dependency Inversion Principle
- High-level modules should not depend on low-level modules. Both should depend on abstractions.
- Abstractions should not depend upon details. Details should depend on abstractions.
Advantages
- Re-use high-level modules in different contexts.
- Reduces coupling and increases cohesion.
- Increases separation of concerns.
- Makes unit testing easier as it allows low-level module injection; for example Mocks.
Inversion of Control (IoC)
Objects do not create other objects on which they rely to do their work. Instead they get their dependencies from an outside source.
IoC Frameworks:
See also: “What is S.O.L.I.D?”
No comments:
Post a Comment