Sharing the Code

Programming stuff that might be useful to others

3 Tier Architecture For Mobile Development

As a way to learn mobile development I made an iPhone app which I subsequently ported to Android. I felt it important to at least support 2 platforms so that I would learn how to design apps with cross-platform in mind from the start. I’ve come to the conclusion that 3 tier architecture, which is familiar to those in enterprise web development, would be useful in dealing with the cross-platform issue.
3 Tier Architecture
The basic idea is that the core of the application would reside in the domain layer. The interface to the domain and service layers would stay constant so that the domain layer can be easily translated to a new language on a different platform. The UI layer could interact directly with the service layer if there is no application logic in the operation. For example, the UI might show a list of items and can get that directly from a DAO (data access object) but if that list needs to be processed first it should be done in the logic section rather than the DAO or UI layer.

The UI layer consists of things like, on iOS, view controllers and on Android activities. You have to be careful to keep application logic out of this layer as much as possible.

In the domain layer, the model section contains your POJOs (plain old Java objects) and the logic section would use DAOs and other services from the services layer and return data to the UI layer.

The service layer would abstract features of the device like database access, network access, location etc. for the domain and UI layers. It would not only be a wrapper on the device specific API but it could also simplify access to the feature so the domain layer can concentrate on the application logic. For example a location service might deal with different ways of getting one’s location either using GPS or cell towers but the other layers don’t have to know about that implementation detail.

Comments are closed