I plan to create an application on iOS, Android and a website with AngularJS.
But for not having to rewrite the business code on each app, I would like to reuse as much code as possible.
To be able to execute the core of the project on any platform, I have to use a web language.
Through different articles, I plan a common architecture to separate the business logic of the project - core - with the UI which will reimplemented for each system (UIKit for iOS, AngularJS and Polymer for the webapp, etc.)
The goal of this architecture is to respect important software engineering principles such as information hiding by decomposing requirements in modules, DRY and SOLID
- Each feature will be decomposed in module.
- Core: Business logic code - reusable on every platform - will be represented in form of a library.
- View: The view class will be developed on each different platform to use the different UI elements proposed on each platform. E.g.: subclass of a ViewController in Objective-C / Swift for iOS or a simple class to manipulate HTML for the web-app. There is no logic in this class. It is only responsible to:
- Handle user interactions to the business logic.
- Display contents from the business logic
- IView: Interface which abstracts the class which manipulates the view.
- Presenter: Link between the Interactor and the View to drive the UI.
- Interactor: The logic of the module, such as algorithms.
- Data Store: Manage the persistence and the fetching of data by communicating with a database or API or web-service.
- Model: Data represented in structures.
Here for iOS (almost the same for Android):
The code of "core" will be executed through a virtual machine as this article shows us: http://www.skyscanner.net/blogs/developing-mobile-cross-platform-library-part-3-javascript
Here for AngularJS:
Now that you know everything about the architecture, here are my questions.
I don't have enough experiences and feedback on the web-langages to be able to make a smart choice. After few researches, I found that there are various options:
Dart:
- Question 1: Are there mechanisms to allow interoperability between Objective-C/Swift and Java through VM? I know that both platforms have VM to execute Javascript code and Google provides dart2js to compile Dart to Javascript code. But it's not plain Javascript: See an example here. So I don't know if there is still a proper interoperability.
Javascript ES6: Event if it's not fully implemented in browsers yet, it's possible to start using ES6 with Traceur compiler.
- Question 2: Is there interoperability of Javascript compiled by Traceur and the VM in iOS/Android?
- Question 3: Is it "safe" to use ES6 through Traceur to develop a large-scale project and have production code?
Thank you for reading.