Yan Cui
I help clients go faster for less using serverless technologies.
This article is brought to you by
I never fully recovered my workspace setup when I upgraded my laptop two years ago, and I still miss things today. If only I had known about Gitpod back then…
Definition:
Dependency Inversion Principle refers to a specific form of decoupling aimed at rending high-level modules independent of the low-level modules’ implementation details. Its principle states:
- High-level modules should not depend on low-level modules, both should depend on abstractions.
- Abstractions should not depend upon details. Details should depend upon abstractions.
Dependency Inversion Principle is often talked about in connection with Inversion of Control or Dependency Injection.
Purpose:
Even in N-tiered applications you can often find tight coupling between the different layers, usually from upper to lower layers but not vice versa. For example, whilst your business layer might be intimately familiar with and dependent on your data access layer, the reverse is not true. This however, still represents a coupling problem and it:
- makes changes to the data access layer more difficult as it might require changes to the business layer (ripple effect)
- makes it hard to unit test the different layers in isolation
Dependency inversion (and decoupling in general) allows software architects to design their systems with greater flexibility by loosening up the dependencies between the different layers of their system.
Parting thoughts…
- Coupling is like radiation, there are harmless background coupling everywhere (say, the core .Net libraries!), but exposure to tight coupling across the service boundaries/between interconnected modules in your application can be hazardous! With that said, without any coupling your system is as good as useless.
- Tight coupling restricts a system’s ability to change in an industry where the only constant is change!
Further reading:
Loosen Up – Tame Your Software Dependencies For More Flexible Apps (MSDN article by James Kovac)
Robert C. Martin’s article on Dependency Inversion Principle
Design Pattern – Inversion of Control and Dependency Injection (by Shivprasad Koirala)
Whenever you’re ready, here are 3 ways I can help you:
- Production-Ready Serverless: Join 20+ AWS Heroes & Community Builders and 1000+ other students in levelling up your serverless game. This is your one-stop shop for quickly levelling up your serverless skills.
- I help clients launch product ideas, improve their development processes and upskill their teams. If you’d like to work together, then let’s get in touch.
- Join my community on Discord, ask questions, and join the discussion on all things AWS and Serverless.
Pingback: Core Spring via Interface21~SpringSource~VMWare « TechnoBuzz