Dependency Injection | Much Easier now… :)

Dependency injection plays a key role in software development this term may seem to be new for few developers but it’s been from quite a long time.

The word dependency injection states that you are trying to inject some dependencies that is components from outside into a class.

These components might be a network call library like http, retrofit so on.., image loading library like glide, Picasso…

Photo by Mister B. on Unsplash

Dependency injection helps you in various ways in terms of software development, testing code re use.

These small independent components play a important role in development of a software and can be replaced easily when required.

There are DI frameworks like dagger, dagger 2, dagger hilt by using which we can achieve this mechanism.

It might sound confusing for few but go through the below example there is a clear explanation of the topic .

When do you require DI (Dependency Injection) ???

When the software you are going to develop is of a large scale or when you want to avoid even the smallest chance of producing a bug then you can go for DI.

Also dagger 2 implementation is explained below with easy examples.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store