Tuesday 13 January 2009

The D in SOLID

Dependency Inversion Principle

  1. High-level modules should not depend on low-level modules. Both should depend on abstractions.
  2. 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.
The technique by which low-level objects are injected into high-level objects is called dependency injection.

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

Followers

Contributors