References for MVP for Android - android

I want to implement MVP pattern for my Android application along with Dagger and RealmDB. I am a complete noob in these concepts. I have referred https://android.jlelse.eu/mvp-dagger-2-rx-clean-modern-android-app-code-74f63c9a6f2f . The blog post though good lacks a bit of explanation about the code demonstrated.
Can anyone recommend good blog posts with explanations which I can follow to implement MVP, Dagger and RealmDb in my app? Any help is highly appreciated.

first I say check ORM's benchmark and choice your decide about your ORM. Don't worry about learning new ORM because it's too easy. here is a benchmark of ORM's ORM's benchmark
Architecture One
first choice is using MVVM. This is a good architecture that you can find many article and blogs in internet. The best benefit if MVVM is you can use is beside data binding that is a great library that support by google and is very useful. Databinding make your project more scale-able and easy to maintenance.
Architecture two
Second Article is going beyond MVVM and databinding. It's using Android Architecture Components . It's couples of component's that introduce and support by google. this components include Databinding,LiveData,Lifecycle,ViewModel,RoomDB,... that google has a good documentation for them and how to use them together.
benefits of this architecture can find in this sentence from google:
Android architecture components are a collection of libraries that
help you design robust, testable, and maintainable apps

Related

Which architecture is suitable for realtime chat application like whatsapp?

I want to develop a real-time chat application in Android like WhatsApp or telegram
for the all-purpose client should connect to the server via WebSockets and even
offline or online has to works fine. I decided to use Android architecture like MVP, MVVM, and MVI, but I'm confusing which one is suitable for my app
Can anyone help me to choose one of them?
And my second question: is it ok to use WebSockets for all APIs or it should better use WebSockets and REST APIs together?
Thanks for your help
There are quite a few patterns out there for app architectures. The most well known are the classic three-tier architectures such as:
MVC: Model-View-Controller.
MVP: Model-View-Presenter.
MVVM: Model-View-ViewModel.
All these patterns represent the main similar idea — to structure your project’s code in a way that it is separated by the different generic layers. Every layer has its own responsibility. That’s why your project becomes modular: separated code parts are more testable, and your app is flexible enough for continuous changes.
MVP is strongly recommended because a lot of developers are using it now. Even, Google also provides its best practice example on Github. You can see full document here.
I strongly recommend you use MVVM because Google has adopted this approach for Android Projects recently. You can find a lot of examples about it. Especially LiveData and ViewModel mechanisms have a lot of advantages in terms of separation of concerns and managing the relations between ui and data.

Android Architecture Questions

I've been reading about architecture to android projects. And I found some stuff, but I guess I misunderstood some concepts or not even understood at all.
One of my questions is about handling api objects, if I have a local database, Should I use the same object from api to store in local database?
I'm also looking for explanation about why use MVVM or MVP, actually they looks like different stuff, I have figured out that MVP is a pattern more concerned about handling UI responsibilities, MVVM I think is oriented to handle communication between UI and database. So I misunderstood the concepts or it make sense?
The last but not least important topic is about dependency injection, I have read about the concept and this question came to my mind, why should I use any framework as dagger to handle this, if I can handle this pattern by myself, once it's not thaaat complicated?
Should I use the same object from api to store in local database?
It can really depend on how good your API object is. You should rather base your local database object on what it really mean in a logical way and if your endpoint is well done it could be the same. The important part in your architecture is to isolate your logic parts from your I/O parts (UI, database, API) so if you want to redesign your UI, change the Webservice you use it will not be too painful.
So I misunderstood the concepts or it make sense?
I am not that familiar with MVVM so I can not really answer that question. But for me the important is not to follow "by the book" one pattern or another but rather to adapt your architecture from what you like from each. I currently try do to so with the Clean Architecture. You can take a look at all the concepts Uncle Bob speak about in this article about making code cleaner and more maintainable.
why should I use any framework as dagger to handle this, if I can handle this pattern by myself, once it's not thaaat complicated?
You don't have to use dagger if you're not familiar with it. But if your project start to grow and you start to be a team of 2, 3, 5... working on it, a framework as dagger can help you keeping a common standard about how you make your dependency injection and then making the code more coherent. Dagger also provide some tools as scopes that can save you some time if you're familiar with it.

MVVM on Android with DataBinding or RxJava?

I am building an Android app and am fairly new to both MVVM and data binding concepts on Android.
I have read at a few places ( like here) that both RxJava and Google's DataBinding library can be used for implementing MVVM pattern.
I went through the official Android documentation for DataBinding and am going through a project referenced by Google on Mvvm using DataBinding. However, I have no idea how RxJava works as of yet, which might be obvious from the question.
My question is, keeping in mind the long term goals of extending my app, is it worth investing effort in learning RxJava? Or does DataBinding suffice as a complete substitute for it? I don't know RxJava at all but by reading about it online gives me the impression that it can solve a wide range of problems.
I do not mind investing time in learning RxJava but is it worth the effort than simply using Google's DataBinding (which I have some sort of grasp on)?
RxJava is a completely different concept than DataBinding. It's more of a way of handling concurrency than it is about binding data. I 100% think it's worth learning. The Android community has embraced it with open arms.
Shameless plug: I compiled a list of RxJava resources awhile back - http://gregloesch.com/dev/2014/10/20/resources-for-learning-rxjava-android.html

Is Model View Presenter and Dependency Injenction becoming a new Standard for Android Development?

In the last period i am having the chance to develop some apps for personal reason, and taking a look to what today the companies are organizing their work in the Android Ecosystem i encountered many and many times this kind of project configuration:
MVP (Model-View-Presenter) as Design Pattern for app architecture;
RxJava for Reactive programming event-based;
Dagger2 for dependency injection;
ButterKnife for fields binding with annotations, used in combo with Dagger2 in order to make your life simplier;
Espresso and Mockito for testing (really nice to use in this kind of environment with this kind of settings)
So, is this becoming a new standard, in your opinion? If so, do you think that is a good idea apply this (relatively) new guidelines and you usually use this kind of project tools/pattern/libraries into your apps or you think there is something better? If you don't like, it, why? What do you think could be a better approach?
(Obviously each project is different, and for each project is always better engineerize the best solution/architecture possible for the kind of users/team/dev involved. I am trying to understand/discuss this kind of model that seems to become widely used in his concept in many, many companies)
Thank you for your time, i hope to create an interesting discussion on the argument in order to all improve our skillset/projects.
Enjoy your day!
We can not say above methods as standard because Android-Sdk does not have any official support from its Libraries and API's. But As far as development environment is considered now a days Developers are using these methods for writing better code base for their apps, better understanding for future development.
As per my knowledge using these libraries is useful only if they have good support from developers as these are open source libraries. For example I am using AndroidMVC right now for MVP pattern. As per my knowledge this is very good library as I am using it since last year but As there is only one developer working on that library, it's very hard to get support for bug fixes(forget about enhancements).
So while selecting any open source library you should always look all the parameters like support, enhancements, bugs etc.
Libraries like Glide, ButterKnife, OkHttp, Couchbase lite, retrofit, Volley etc are some evergreen libraries of Android.
But again OkHttp, Retrofit and Volley are used for similar purpose i.e. for networking. Now developer have to choose according to pros and cons of each library.
As far as question - should we use libraries or not? is considered. I think YES. We should use these kind of libraries which are stable because it saves lot of time and it's not of use rewriting the code if we already have it in form of library.

Android MVP implementation

i came across a few articles talking about the subject but i cannot understand how to apply MVP on my app code. is there any specific guidelines for a clean MVP implementation for android.
thank you
Checkout this link:
Material movies
MVPAndroidBootstrap
Clean-Contacts
MvpCleanArchitecture
Android-CleanArchitecture
At this links you will find a lot of MVP implementations for android
UPDATED:
mosby - A Model-View-Presenter library for modern Android apps
ThirtyInch - A new MVP library for Android
Moxy - Android MVP library without problems of lifecycle and boilerplate code
UPDATED:
Interesting-Android-repositories - contains a lot MVP implementations for Android.
Here on github
https://github.com/saksham24/Android-Firebase-Mvp-Mvc-Mvvm-chat
i made a repo containing 3 applications with same functionality but written in 3 different android patterns(Mvc, Mvp, Mvvm)
Understanding three different pattern is quite easy if we get a simple good example on them so i made a repo to contribute my knowledge to this developer community.
Also the repository is written using proper java guidelines and conventions(including naming and packages, modules) so people looking for such project can also view this repository.
I've recently created lightweight (with no overhead dependencies) MVP library in Kotlin. It also supports LiveData subscription between Presenter and Model under the hood.
Please find detailed "how-to" and sources here: https://github.com/smaslenko/instant-mvp

Categories

Resources