From the course: Android App Development: Design Patterns for Mobile Architecture

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Interface injection

Interface injection - Android Tutorial

From the course: Android App Development: Design Patterns for Mobile Architecture

Start my 1-month free trial

Interface injection

- [Instructor] We've gotten to the point where we're injecting all of our dependencies, but we are still tied to the concrete implementation of each of these layers. The next step to further decouple us from them is to start using interfaces instead of actual implementations. The easiest way for us to go through this is to come into this dependency registry and start changing it. I'm going to name this external dependencies instead of just realm. We'll move our JSON into here as well. These we're going to keep as their current types because they are external dependencies you could wrap them in another class, but to keep things more simple, we're just going to go through and only change our own types. In this case, we're going to go into the spy translator. We're going to select the class name and press Control T, and we want to extract interface. In this case we want both of these methods extracted. We'll rename the original class and we're going to just use impl and keep the…

Contents