Tight coupling vs. Dependency Inversion

Alireza Bonab
2 min readApr 1, 2020

I guess no one more than software developers is fascinated with technology advancements. We are eager with trying new technologies and learning them especially in term of software.

Problem

This is great, you work in a company or founded a startup and as tech person always want to learn new things ( frameworks, databases, UI components and etc. ) but what prevents you to bring or apply new advancements to your software platform, thing that can improve User Experience and Performance.

image from vectorstock

One of the reasons you can not change the platform and stuck with the current frameworks and databases or etc. is Tight Coupling. Yes, Tight Coupling in the heart of your platform prevents you to change it because change means a lot of unwanted consequences and extra work.

Solution

Tight Coupling vs. Dependency Inversion Principle

SOLID is an acronym for 5 important design principles when doing Object Oriented Programming, These principles introduced by Robert C. Martin (Uncle Bob) and then named SOLID.

There is a pattern called Dependency Inversion Principle which is a part of SOLID principles, This pattern in software development says that by introducing an Interface we can change the dependency direction and class which is called by other classes can implement that interface and then we can inject or pass that class as a parameter to the caller classes.

By doing this we will change the source code dependency direction but the flow of control still remains same and higher components do not depend on detail components.

Conclusion

The conclusion is pretty simple, If while we are growing our software platform considering SOLID principles and specially Dependency Inversion Principle then changing a database with another one becomes a lot easier the new database layer only needs to implement required interface and functions for Read/Write this can apply to any other peaces of the software.

We keep core logic independent from frameworks by Dependency Inversion Principle and enjoy introducing new advanced solutions to our platform.

Alireza Bonab

Entrepreneur in Spirit, Engineer by Training, Adventurist by Nature