Dependency Injection & Inversion Control

Steven Klavins
2 min readApr 5, 2020

--

Dependency Injection, sounds like a scary concept doesn't it? No doubt it can take some time to get to grips with but it isn't as scary as it sounds. Dependency injection more or less states its purpose in the name, we inject (or implement) a dependency into a class that requires it.

So let's say we want to access a database of university students and implement the information from this database into our code. Now this is where dependency injection shines, our dependency is the database of students and the class in question would be the destination in which it needs to be injected.

This is a concept that you would no doubt use over and over whilst working with frameworks and it has many benefits that make the life of a programmer far more palatable. Just some of the benefits of using dependency injection are; you are not always required to rewrite complex code to deal with your dependencies, you allow a lot more flexibility for future implementation of your program and testing your program can often be a lot easier through the avoidance of hardcoding the dependencies.

There are many videos surrounding this subject but here are three of my favorites, they touch on the use or interfaces and some frameworks such as spring and SQL which are fairly large subjects in themselves.

Thanks for checking out this post, there will no doubt be plenty more on this subject to come in the near future.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Steven Klavins
Steven Klavins

Written by Steven Klavins

Hi, I’m Steven, most call me Steve! I’m a programmer, musician, and artist. This blog contains various tutorials and posts related to software development.

No responses yet

Write a response