How did I learn Android Clean Architecture, Dagger2, and Retrofit?

Navid Ghahremani
5 min readMay 7, 2021

--

The story that I am telling you today is more like guidance than technical coding.

I heard about Clean Architecture in a meetup a while back ago, and I was wondering how would it be if I could bring it to one of my personal projects. I researched about it a lot and honestly the more I looked into it the more I got confused. The time that I was looking for it which might be over a year ago, everywhere I looked, either was not explaining it enough or it was overwhelming. So my journey of learning started.

First thing first: Tutorials

I do have this thing, I really don’t enjoy reading the long explanation for something that I can understand from two lines, so tutorials are the best for me to start, they go right straight to the topic :D

So, once I started reading, I figured out people understand Clean Architecture in their own way and none of them are the same; I realized tutorials are not fit for this as I need to get more deep knowledge and come to my sense about it. So, I stop reading them shortly after I started (I mean after a week!!!) but I have to say; I understood one thing, the clean architecture is not good for Microservice architecture which I am doing for several years now, but it fits best for Monolith applications or more mobile apps which are a kind of Monolith too. Here are some of those that I had to read before I stop.

I really liked the below ones:

Next: Github

So, the next try for me was Github, I said, I am a coder; I understand code, so let’s see the Clean Architecture in action, and to be honest, it was not a bad idea, but it was not enough. Anyway, I finally found some excellent resources that help me understand more.

These repositories helped me to understand what is going on and how can I join the layers together and preventing coupling. My mind started shaping to think like Clean Architecture way when I am coding. It was getting more visible to me why we need it, especially in mobile apps.

So, the code helped me to understand, despite that; I needed more experience before I code; I needed someone to explain to me more about it which the next step of my journey did the trick.

The magic: The greatest, the YouTube

I love Youtube; it is such a great website that you can learn anything from it. I said if I see someone in action, I might pull it off. So I started watching Youtube videos for a week almost 8 hours a day and still nothing till I found these videos, they enlighten me on how everything works and come together despite decoupling. Especially the talk from Marko Milos (The first video). Thank you, Mr. Milos.

Now, I was ready to take off and do it on my own, then I realized it is the toughest part of my journey even though I was thinking the learning is. Silly me.

I am saying it was the toughest part, because; I started with a mobile application and it seems Android is becoming more and more complex compare to the time I was developing an Android application which goes back many years ago (Android 2.3 and 4). I had to learn Dagger2 for the dependency injection which is the most important part of the Clean Architecture. Basically, I think without injection; it is better not to do it. I cannot explain how difficult it was for me to understand all of those stupid Dagger2 relations. I am an experienced Spring Boot developer and DI in Spring is super simple, but Android DI is ridiculously hard and complex. But in case you are interested, I finally pulled it off with the link in which was good.

Then, I had to learn retrofit and other cool technologies that companies brought them in Android to make Android programming much more fun. My method of learning was kind of similar to how I learned Clean Architecture.

Conclusion:

After an endless journey of learning Clean Architecture, it was worth it. It is a great architecture for monolith applications and it saves you a lot of time for future changes even though you have to waste some time in the beginning or when you create a full-stack component from presentation to model and data layer. It separates the concerns well in which you can easily change every part of your application without affecting other layers that much.

Finally, you need to do your own research and make it sense for yourself. Do not be down if you do not understand it well in the first months, it is hard; it happens to many people I know including myself but once it clicked; you see everything clearly.

Contact Me:

Hope this article helps you out a bit on your journey. Do not hesitate to contact me via my Twitter (https://twitter.com/navid_gh) or in the comment section here. Also, you can find me on my Linkedin (http://linkedin.com/in/ghahramani)

Please clap if you like the article and my journey alongside the resources I provided.

--

--