oop - What is the dependency inversion principle and why is it important? -


what dependency inversion principle , why important?

check document out: the dependency inversion principle.

it says:

  • high level modules should not depend upon low-level modules. both should depend upon abstractions.
  • abstractions should never depend upon details. details should depend upon abstractions.

as why important, in short: changes risky, , depending on concept instead of on implementation, reduce need change @ call sites.

effectively, dip reduces coupling between different pieces of code. idea although there many ways of implementing, say, logging facility, way use should relatively stable in time. if can extract interface represents concept of logging, interface should more stable in time implementation, , call sites should less affected changes make while maintaining or extending logging mechanism.

by making implementation depend on interface, possibility choose @ run-time implementation better suited particular environment. depending on cases, may interesting too.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -