{"id":468,"date":"2019-08-03T13:02:30","date_gmt":"2019-08-03T12:02:30","guid":{"rendered":"http:\/\/toptechytips.com\/?p=468"},"modified":"2020-06-03T12:07:48","modified_gmt":"2020-06-03T12:07:48","slug":"lets-deep-dive-into-android-project-architecture","status":"publish","type":"post","link":"https:\/\/dotslaz.com\/lets-deep-dive-into-android-project-architecture\/","title":{"rendered":"Let\u2019s Deep Dive into Android Project Architecture"},"content":{"rendered":"
Let\u2019s Deep Dive into Android Project Architecture Cause people are using what we are developing, and users want more features, and your client pushes you to add features or change features. We also know that the one and only constant in software development is \u201cCHANGE<\/strong>\u201d. That\u2019s where you are late to join the party, that we are already taking advantage of. Yes! You are right, you can develop applications without following any architecture, and even you can make the application bug free as well without the following architecture. Then why? When we started with Android most of us only know about Activity, Fragment is default classes provided by Android to write codes. And we only write some other classes like Adapters and other things. But only care about the Activities and Fragments. Where we do all the things like any UI stuff, network calls to get data from a server and even make a query into the local database to get data and then bind that with the UI. When I started writing this article, I was fearing this question of you, I did know that you will throw this to me. But I thought I have an answer for you.<\/p>\n This pattern was the only thing for the mobile and web developer when they just need to separate the business logic from the UI and also where business logic doesn\u2019t need to change much like the UI<\/p>\n This pattern is very new and future-oriented and also recommended by the Android JetPack team. And the pattern actually<\/p>\n This pattern is the most used Architecture of the Android community! And the one and the only reason is the Presenter itself. We will explore it with a very simple example project as we are selecting this pattern to deep dive into the Android project architecture<\/p>\n But the real answer is, it\u2019s completely up to you, Every architecture have different pros and cons, but I suggest you start from the MVP<\/a>, and later on you can switch as per your needs and will!<\/p>\n Hint<\/strong>: I assume that you have basic knowledge about Android development and Android Project Architecture. So I am not going to discuss how to create a project or the other noob things.
\nHello World!<\/strong>
\nWhen I started coding with Microsoft Visual Basic, from then my only intention was to make things work. I think for most of the programmers, this happens at an early stage of their carrier. But when we get the chance to write our first line of code that I am actually paid for, after that very soon we can realize that we also have to care about our codes.<\/p>\n
\nI know you have a question in mind, If my application runs well without any error, then why are you pushing me to those complex and messy things?<\/p>\nWhy you follow Android Project Architecture?<\/h3>\n
\nI did appreciate your question, just a few months away from now, but now I can realize why \u201cUncle Bob\u201d wrote a whole book on clean coding and architecture. The one and the only answer are to make your code \u201cReusable, Readable, Testable\u201d and believe me you will give me Thanks when you deep diving into it really! And it\u2019s more than worth it to start diving into it.
\nI should tell you that, you will get tons of articles over the internet about how to use MVP, MVVM, MVC without even knowing why to use?
\nThat\u2019s why at first I tried to answer some of them!<\/p>\nSo let\u2019s start the journey!<\/h2>\n
\nAnd when your project gets bigger and bigger, you see lots of Fragments and Activity full of codes, sometimes 1000 thousand lines and above. And you start to think of yourself a great programmer as you have already written this much codes, and it\u2019s working and going in production and also people already started using it.
\nBut when you open the project after 1 month or 2 months you will deep dive into the \u201cMariana Trench<\/strong>\u201d the deepest point on the sea known by until now.<\/p>\nWhich is the best Android Project Architecture? MVP, MVVM, MVC, Clean Architecture?<\/h3>\n
MVC (Model View Controller):<\/h3>\n
\n
MVVM(Model View ViewModel):<\/h3>\n
\n
\u00a0MVP(Model View Presenter):<\/h3>\n
\n
Let\u2019s start learning the MVP pattern, Later you can switch by yourself. I know you will!<\/h3>\n
\nOur main target is to separate the business logic from the UI.
\nWe are now writing a very simple application just to show a simple list of students in a screen, I know you have made 100x complicated thing until now. But if you haven\u2019t used MVP earlier, this small thing will make you happy!<\/p>\n