Android app and (Android) archi library

I am working on developing an application for Android, and I have a few questions that I would like to express my opinion on.

Currently, the architecture I'm thinking of is this:

  • Android app for user interface,
  • A library (Android or pure Java?) For business logic,
  • Android library for accessing SQLLite databases (will be used by business logic),
  • Android library for accessing Wifi / BT modules (will be used by business logic).

Architecture quick schema

Since it is very likely that in the near future the Java version of this Android application can be developed for Win / Mac / Linux, I try to ensure that the business logic does not differ from the specific Android APIs.

In principle, business logic will need to use the built-in SQLite database, as well as use the BT adapter and access to the Internet via Wi-Fi, for example, this can be done using two dedicated Android libraries. The problem is that I would like Business Logic to be just a β€œclean” Java library and not be based on the Android project. Is this possible according to this architecture, knowing that it is possible that the Android application will have a configuration β€œmodule” responsible for setting up and configuring and launching two Android libraries if necessary.

Does the currently selected architecture have in your eyes?

What could be your advice for this application:

  • Be as modular as possible with a good level of abstraction (on a DB adapter and BT / Wifi),
  • Keep your business logic as high as possible in the Android API,
  • Require minimal changes to adapt this entire solution for a classic Java application.

Thank you in advance for your time and opinions.

+4
source share
1 answer

I asked a similar question - I was trying to develop an application for Android, Blackberry and, possibly, J2ME. I did this by implementing platform components (user interface, database access, network access) separately from the main business logic. The BL core was developed as a regular JAR library, which I distributed in Android and BB applications.

Although this worked, I was not satisfied with the decision. As I explained in the answer here , (and as even the answers to my first question mentioned above), I ran into practical difficulties since BB / J2ME could not cope with Java releases. My Android implementation ended up using a lot of "outdated" code (for example, no generics).

Having said that, since your next goal is to switch to a desktop computer, and not to BB or J2ME, you can not only support the overall design of your Android and Java desktop applications, but also share implementations.

As for your question about abstraction, I would suggest a business logic approach based on an interface and DB Logic. The link in the first paragraph of my answer above shows a simple example of how to achieve this, but I would be happy to provide more detailed information.

+3
source

Source: https://habr.com/ru/post/1392910/


All Articles