4

I am working on designing an Android application, and I have several questions I would like to have your opinion on.

Right now, the architecture I am thinking of is the following:

  • Android application for the User Interface,
  • Library (Android or "purely" Java?) for the Business Logic,
  • Android Library for accessing SQLLite Databases (will be used by the Business Logic),
  • Android Library for accessing Wifi/BT modules (will be used by the Business Logic).

Architecture quick schema

Since it is very likely that in a close future a Java based version of this Android application might be developed for Win/Mac/Linux, I am trying to keep the Business Logic as much apart from Android specific APIs.

Basically, the Business Logic will need to use the embedded SQLite DB as well as use the BT adapter and access the Internet through Wifi for example, this could be done using the two dedicated Android Library. The issue is that I would like the Business Logic to be only a "pure" Java library, and not built upon an Android project. Is that feasible according to this architecture, knowing that is is possible the Android Application will have a configuration "module" in charge to setup and configure and initiate if needed the two Android based libraries.

Does the currently chosen architecture make sense in your eyes ?

What could be your advice for this application to:

  1. Be as modular as possible with good abstraction level (on DB and BT/Wifi adapter),
  2. Keep the Business Logic as much as possible clear from Android APIs,
  3. Require minimal changes to adapt this whole solution for a classical Java application.

Thank you in advance for your time and opinions.

Vincent B.
  • 524
  • 3
  • 15
  • Just check this link [What is Android?](http://developer.android.com/guide/basics/what-is-android.html) you will get an idea about android architecture. – Yugandhar Babu Jan 25 '12 at 12:13
  • @YugandharBabu: Thank you for the link, but the issue here is more about trying to keep code out of Android scope a maximum, using libraries to isolate a maximum functions requiring access to the Android device HW or specific features. – Vincent B. Jan 25 '12 at 12:52

1 Answers1

3

I had asked a similar question - I was aiming to develop an app for Android, Blackberry and possibly J2ME. I did this by implementing platform-specific components (UI, DB access, Network access) separately from core business logic. The core BL was developed as a common JAR library that I distributed to Android and BB apps.

Although it worked, I was not really satisfied with the solution. As I explained in an answer here, (and as even the answers to my first question above mentioned), I faced practical difficulties since BB/J2ME have not kept up with Java releases. My Android implementation ended up using a lot of "legacy" code (no generics, for example).

Having said that, since your next aim is to go desktop rather than BB or J2ME, you might be able to not only keep your design between your Android and desktop Java apps common, but also share the implementations.

Regarding your question about abstraction, I would suggest an Interface-based Business Logic and DB Logic approach. The link in the first para of my answer above shows a simple example of how to achieve this, but I would be glad to provide more details.

Community
  • 1
  • 1
curioustechizen
  • 10,572
  • 10
  • 61
  • 110
  • Thank you for your answer and link to previous question I didn't found before posting mine. In my case the JDK version used for the Business Logic will be the latest one supported in Android, which should be v1.6, and thus 1.6 on desktop platform is also alright. About Data access, yes the system will be improved and has been simplified for clarity purpose. Though one question about the core BL, is there any trick to perform the reference the Android libraries in a classical Java Project (dependencies or use the android.jar lib) ? – Vincent B. Jan 25 '12 at 12:47
  • Yes - as I mentioned, you won't be bothered by the JDK version constraints that I had- which translates to better code reuse between platforms. – curioustechizen Jan 25 '12 at 12:49
  • You can use the android.jar library in a classical Java project - this will allow compilation if you reference Android-specific classes. I discourage this approach though. Your core BL library should be self-contained and should also **compile** independently of the actual target platform. – curioustechizen Jan 25 '12 at 12:54