Bespoke Android App Developers: Android App Architecture
As opposed to classic desktop apps (think Word and Excel before Office 365), which open their default opening screen from the Start menu or desktop icon and then run as a single process, an Android app tends to contain many different components such as activities, services and broadcast receivers which we declare in the Android app's "manifest" file and it is the actual Android operating system which uses this manifest file to decide how best to integrate your app into the phone/tablet user experience.
For example, let's say your field engineer is using one of the bespoke Android apps we have developed for you and as part of the workflow he/she needs to take a photo or video which will be saved to that particular job - the steps for the Android operating system to deal with this scenario would be similar to:
Our Android app requests the camera to take a photo or video and the Android OS then launches the device's camera app to handle the request.
At this precise point in time your user has actually left the bespoke Android app we developed for you, however, their experience is still seamless (as far as they are concerned they are still on our app).
The device's camera app might allow users to do other tasks (e.g. launching the file chooser) which will launch yet another app.
In the end (i.e. when your user has taken their photo or video), he/she returns to our Android app and can see the photo or video they just took listed on say their job screen.
At any point during the above process the user could be interrupted by a phone call or notification. After acting upon this interruption, the user expects to be able to return to, and resume, this photo/ video taking process. This app-hopping behaviour is very common so the bespoke Android app we develop for you must handle these flows correctly.
Bear in mind that Android phones and tablets have limited memory so at any time the Android operating system could kill some app processes to make room for new ones.
Given these conditions it's highly possible for various app components to be launched individually or out-of-order and the operating system (or indeed the user) could destroy them at any time. Because these events aren't under our control, we do not store any app data or state in the app components and neither do we allow app components to depend on each other.
Separation of Concerns
In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections, so that each section addresses a separate concern (a concern being a set of information that affects the code of a computer program).
Unfortunately it is still very common (especially with novice developers) to write all their programming code in a User Interface UI class (e.g. an Activity or Fragment), however, these classes should only contain the logic that handles UI and operating system interactions as otherwise you risk encountering lifecycle-related problems. For example, because of low memory the Android operating system could destroy a UI Activity or Fragment and therefore it is important that the app's main logic does not depend on these UI classes.
UI Managed by Model
Models are components that are used for handling the app's data. They are independent from the other UI app components and therefore unaffected by the app's lifecycle. Ideally we should use a persistent model for the following reasons:
- Your users don't lose data if the Android operating system destroys your app to free up resources.
- Your app continues to work in cases when a network connection is unreliable or not available.
By basing the bespoke Android apps we develop on model classes with well-defined responsibility for the management of data, the Android apps we develop are both more testable and robust.
Android app architecture refers to the way an Android application is structured and organized to achieve a certain level of maintainability, scalability, and testability. There are several popular architectures used in Android app development, including:
Model-View-Controller (MVC): This is one of the oldest and simplest architectures. It separates the application logic into three components: Model, View, and Controller. The Model represents the data and business logic, the View represents the UI, and the Controller acts as an intermediary between the two.
Model-View-Presenter (MVP): This architecture is an evolution of the MVC pattern, with a stronger separation of concerns. The Presenter acts as a mediator between the Model and View, and handles all the business logic.
Model-View-ViewModel (MVVM): This architecture is designed to support data binding and simplify the UI code. The ViewModel sits between the Model and View, and handles the business logic and data transformations.
Clean Architecture: This architecture separates the application into layers of responsibility, with each layer only dependent on the layer below it. This creates a modular and flexible application that is easy to maintain and test.
Reactive Architecture: This architecture uses reactive programming techniques to build more responsive and resilient applications. It often includes libraries such as RxJava and LiveData to manage asynchronous data streams.
Choosing the right architecture for your Android app depends on several factors, including the size and complexity of the application, the development team's expertise, and the project requirements.
Android App Architecture is a vital concept for app developers. It refers to the fundamental structure and organization of an Android app's codebase, which defines how different app components work together to provide the desired functionality. By following a well-designed app architecture, developers can create apps that are scalable, maintainable, and easy to test and debug.
App developers use Android App Architecture in their apps by choosing a suitable architecture pattern that aligns with their app's requirements. The most popular architecture patterns used by Android app developers are Model-View-Controller (MVC), Model-View-ViewModel (MVVM), and Clean Architecture.
In MVC architecture, the app is divided into three components: Model, View, and Controller. The Model represents the data and business logic, the View displays the user interface, and the Controller mediates between the two. App developers use this pattern to create apps that have a clear separation of concerns, making it easier to maintain and update the app's codebase.
MVVM architecture is an evolution of MVC architecture that separates the presentation logic from the business logic. In this pattern, the app is divided into three components: Model, View, and ViewModel. The Model represents the data and business logic, the View displays the user interface, and the ViewModel provides the presentation logic. App developers use this pattern to create apps that are easy to test and maintain and have a clear separation of concerns.
Clean Architecture is a modern architecture pattern that focuses on creating apps that are testable, scalable, and maintainable. In Clean Architecture, the app is divided into different layers, each with its own specific responsibility. The innermost layer is the Domain layer, which contains the app's business logic. The next layer is the Data layer, which interacts with external data sources. The outermost layer is the Presentation layer, which is responsible for displaying the user interface. App developers use this pattern to create apps that are flexible, easy to maintain, and have a clear separation of concerns.
App developers also use Android App Architecture to implement various software design principles, such as Single Responsibility Principle (SRP), Open-Closed Principle (OCP), and Dependency Inversion Principle (DIP). By adhering to these principles, developers can create apps that are modular, reusable, and easy to extend.
In conclusion, Android App Architecture is a crucial concept for app developers. It helps them create apps that are scalable, maintainable, and easy to test and debug. By choosing a suitable architecture pattern and adhering to software design principles, developers can create apps that are flexible, modular, and reusable. The choice of architecture pattern depends on the app's requirements, and app developers must evaluate each pattern's pros and cons before selecting one. Overall, a well-designed app architecture is a key factor in creating high-quality Android apps that meet user expectations.
Read more about Android App Architecture