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.
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.
- 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!
Loosen Up – Tame Your Software Dependencies For More Flexible Apps (MSDN article by James Kovac)
Design Pattern – Inversion of Control and Dependency Injection (by Shivprasad Koirala)
I specialise in rapidly transitioning teams to serverless and building production-ready services on AWS.
Are you struggling with serverless or need guidance on best practices? Do you want someone to review your architecture and help you avoid costly mistakes down the line? Whatever the case, I’m here to help.
Check out my new course, Complete Guide to AWS Step Functions. In this course, we’ll cover everything you need to know to use AWS Step Functions service effectively. Including basic concepts, HTTP and event triggers, activities, callbacks, nested workflows, design patterns and best practices.
Here is a complete list of all my posts on serverless and AWS Lambda. In the meantime, here are a few of my most popular blog posts.
- Lambda optimization tip – enable HTTP keep-alive
- You are thinking about serverless costs all wrong
- Many faced threats to Serverless security
- We can do better than percentile latencies
- I’m afraid you’re thinking about AWS Lambda cold starts all wrong
- Yubl’s road to Serverless
- AWS Lambda – should you have few monolithic functions or many single-purposed functions?
- AWS Lambda – compare coldstart time with different languages, memory and code sizes
- Guys, we’re doing pagination wrong