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…
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.