Which architecture is suitable for realtime chat application like whatsapp? - android

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.

Related

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.

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.

Architectures for RESTful Android Applications

I'm currently developing an Android application and I'd like to have an scalable architecture with a clean separation of concerns. The requirements of this application are, mainly:
User autentication (I'm dealing now with Google Sign-In for Android after many unsuccessful fights agains Android Identity Toolkit)
Synchronization with REST services (this application should be collaborative, I've already done a proof of concept to consume a "heartbeat" service, using AsyncService, that was the only way I've found to clean activies code, I got to that library researching about Robust Android Architectures)
ORM at client side to store user generated data and retrieved data in the future (my choice has been ORMLite for Android)
Material Design (as the best approach to the UI I have in mind)
First of all I'd like advices on how to separate classes inside the project, I mean, should I use folders (activity, model, DAL, service, sync...) or should I create my own libraries? (in .Net I'd create libraries with parent namespace)
My second and biggest concern is about user identity: how should looks like my architecture to achieve my goals? (sign up / Sign in with multiple providers, authenticated rest client and synchronization using SyncAdapter)
I hope you don bane this quiestion because maybe is too generic but I ask about all this stuff because I couldn't find information or advices about this stuff.
Thank you in advance.
This is a generic question and every dev has his own way to achieve this, but I would recommend to follow one of the trending patterns right now.
There is a project call the clean architecture. It has pretty much everything from dB to Api. In my opinion is a over-engineered.
I prefer another pattern called Flux.
Together with retrofit, eventbus or Otto makes building apps easy and keep the structure
You can read more about it here:
http://lgvalle.xyz/2015/08/04/flux-architecture/

When one should use "spring for android"?

I came across spring for android, which claims to provide Spring Framework that aims to simplify the development of native Android applications.
If anyone has already used or explored this framework, please share your thoughts about the scenarios or situations where this can be beneficial over standard android framework (which is somewhat like MVVM).
To sum up, I am looking for additional benefits provided by this framework.
I investigated spring for android and my analysis is :
It Does not provide Inversion of control. Provide popular spring tools like RestTemplate, Social Integration for Android .
Spring provides parsing framework as well, thought not as efficient as jackson.
more yet to be added, keep your finger crossed.
this means whenever you want a ready made solution for RESTor Social Integration(fb/twitter) along with a parser with normal capability, spring for android might be a right choice for you.
if someone will post more accurate answer, i will surely accept that.

Design Pattern in Android? [duplicate]

I'm working on an Android project and I would like to know any recommendations about what's a good architecture to build an android application.
I want to use dependency injection using Roboguice and I've been reading about MVVM pattern or MVC pattern (Android MVVM Design Pattern Examples).
Also I know that roboguice have a pretty cool Context-Based Event's raising and handling feature that could be very testable as the code is decoupled.
Any recommendations on a working design pattern? a testable and scalable architecture you have worked with or developed?
The Android platform provides a common set of design patterns, and with the limited hardware resources you get compared to Web-apps it is still often best to stick with using these directly in production code. There are other frameworks that sort of "wrap" the base platform; these are worth looking into if you have a specific purpose (or perhaps for prototyping/experimenting), but for the best level of support you are generally best sticking with the standard components.
This is a great resource when working on UI solutions: http://www.androidpatterns.com/
Specifically for DI: There is a Spring framework for Android, I've had a play with it and it looks quite promising. You've already mentioned Roboguice as another alternative to this. However, to avoid performance and library overhead, I still find the easiest approach is to write a simple reflection-based class that registers and injects dependencies within my own code. Similar to this approach, except I usually move the injection code into a separate singleton and reference it from there.
In my experience most of the third-party offerings are not yet mature enough to rely on right now, and don't really give you much on top of what the base platform provides. They are constantly progressing, however, so be sure to experiment with the big names from time-to-time.

Categories

Resources