MVVM on Android with DataBinding or RxJava? - android

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

Related

References for MVP for 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

Testing Firebase Database with an in-memory fake/db

Is there any in-memory implementation for Firebase database for testing Android client logic and integration? I have seen node.js fakes but could not find anything in java. I am not looking for a plain mock which is only good for basic unit-testing.
You must do refactoring your application, and implement an architectural approach. For example, such as MVP, MVVM, Clean, etc. The main thing is the layers. In this case, you can test these layers independently of each other using mock objects.
On the Internet you will find a lot of documentation on this topic,
eg Essential Guide For Designing Your Android App Architecture,
Why to choose MVVM over MVP — Android Architecture and many others.

Implementing MVVM, Dagger2, Retrofit, Rxjava, LiveData, ViewModel together along with Android testing

I have knowledge of MVVM, Dagger2, Retrofit, Rxjava, LiveData, ViewModel. I did a basic implementation of them together without Fragments https://github.com/karthik5418/android--demo/tree/snapdeal_search
Now I have some doubts in going advanced implementation of them
Do I need to learn DataBinding (i.e is it necessary to get clean code and for testing)
I gone through few blogs for advanced implementation, every blogs is has its own way. Some looks higher level of abstraction, that I thing is not necessary
reference : https://github.com/MindorksOpenSource/android-mvvm-architecture
https://proandroiddev.com/mvvm-architecture-using-livedata-rxjava-and-new-dagger-android-injection-639837b1eb6c
https://medium.com/#iammert/new-android-injector-with-dagger-2-part-1-8baa60152abe
I am confused now, what should I follow for my production ?
Please help me with some reference that I can follow for my production.
check out this repo https://github.com/balwinderSingh1989/MVVMCleanAndroid that contains a architecture structure that you use to kick start your project.
And yes, you should be learning databinding (there's hardly any learning curve involved). Also make sure you explore about binding adapters as well.

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.

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.

Categories

Resources