Controlling everything in your life isn’t possible, that’s an unquestionable truth. However, if something is within your capacity to take a hold of, you should act upon it. This rule applies to mobile application architecture as well.
You can’t control your app’s architecture if you don’t know how it works. In turn, mobile application architecture is a complicated concept to learn about, which means that taking control over this aspect of a mobile development project can be really tough.
That is why the JatApp team will explain the concept of mobile app architecture in bite-sized portions, so that you will not get a migraine afterward. And who can best tell you about mobile development? The one who does it every single day. So, please welcome our iOS Team Lead who agreed to comment on many important things about mobile application architecture. Let’s nail it!
What is mobile app architecture: definition and principles
You can find thousands of mobile app architecture definitions, but since you are here, and we invited our iOS Team Lead to talk about mobile architecture, here’s how he defines the mobile architecture: “Mobile application architecture is a set of decisions and templates which help to build an app’s system that works correctly”.
Please, don’t be angry with us, but mobile app architecture actually simplifies developing a mobile app, as a tech team has various ready-made decisions and strategies to build an app more effectively at their fingertips. Although, our iOS Team Lead warns here that “There is no silver bullet for all types of apps, everything is very individual. When you think about what architecture to choose, pick the one that makes the whole development process simpler. That’s the whole purpose of mobile architecture”.
At the same time, building any mobile architecture follows universal principles that aim to help mobile application developers see the whole picture of the project and reuse the same chunk of code for different purposes within the app. There are three major principles that you need to know: SOLID, KISS, and DRY.
These principles are not just some obscure words, but acronyms. Just take a look at SOLID:
- S — single responsibility principle. A single app’s module must hold a responsibility for only one aspect of the app’s functionality.
- O — open-closed principle. Any part of the app has to be able to extend without problems if needed. But it doesn’t mean that anybody can modify it.
- L — Liskov substitution principle. The principle formulated by Barbara Liskov back in 1987 and it means…We need to make a short pause here. This article tries to explain mobile app architecture in simple words, but we didn’t say anything about explaining it in a few words. So please, bear with us and keep reading the following example.Imagine you have a plain coffee machine that makes only filter coffee. That’s your mobile application. Then, you decide that you want to drink not only filter but espresso, cappuccino, and other specialty coffee. You obviously need to install a grinder to make different coffee drinks. According to the Liskov principle, your coffee machine should be made in a way that allows adding the grinder and making other types of coffee without breaking the entire coffee machine apart and then getting the pieces together. Huh. We hope we made this explanation as simple as possible.
- I — interface segregation principle. The existing interface should not include any new features. If new functionality applies, the interface update is necessary.
- D — dependency inversion principle. The high-level components of your app should not depend on their subordinate parts.
And now let’s make sense of these must-follow guidelines. JatApp’s iOS Team Lead described these principles as “a collection of guidelines we need to keep in mind during the development process in order to write a code that is easy to expand and support”. As a consequence, SOLID principles help a development team coordinate their actions since every mobile developer tries to write code that other team members will easily read and elaborate upon.
This acronym reads as quite a wise advice how to live this life: “Keep It Simple, Stupid”. We don’t recommend talking this way to your tech team, but this is how mobile developers say it to themselves. But we don’t really think that all mobile developers are that harsh on themselves. Such a saying is used just to emphasize how simplification of everything matters for developing a mobile app and its architecture.
The main takeaway of this principle is pretty clear: if there’s a chance to simplify something, your team should go for it. Apart from that, our iOS Team Lead made a comment: “The simplest decision doesn’t necessarily mean the fastest one. It’s quite common that we can spend hours on coming up with the simplest line of code”.
Don’t Repeat Yourself — if you have some part of code that can be used more than once, your mobile developers shouldn’t write it from scratch again. Let them just copy and paste! “Lazy, but efficient” mentality is what you need here to follow this principle. Also, DRY principle suggests that app data should not be repeated across the system in order to avoid confusions and overlaps that evidently harm the app’s quality of performance.
Overall, you can see that the existence of so many principles means that mobile architecture does really make a significant impact on app’s quality. If your app’s architecture is poorly built, you’re likely to face numerous problems, such as bugs, security loopholes, data overlapping, and so on.
Just imagine you assembled IKEA furniture and got some pieces left. They’re not extra, it means that this closet will fall down at any moment. The same thing happens with mobile application architecture. You need to know how you get the parts of your app together. That’s the reason why we explained the principles in the very beginning. And now, it’s time to discuss the building blocks of mobile application architecture.
The same can happen with your app, if it’s architecture is poorly designed
Here come layers
There are three major blocks that create the architecture of any mobile app: business logic, data access, and presentation. The borders between these layers are not necessarily distinct while their relationships depend much on the app’s purpose and the patterns mobile developers prefer to follow. Anyway, we need to take a closer look at each layer:
- Business logic. This layer makes the application perform by providing data caching, data security, logging, data validation, and such. This layer is located at the server side of the app and makes the app’s basic functionality possible.
- Data access. The database and all data transactions can be found at this layer. By the use of application programming interfaces (APIs) that data goes back and forth within the application. Likewise, data routing, error reporting, and service tools belong to this layer.
- Presentation. This is actually the facade of the whole architecture because this layer refers to the user interface (UI) and everything you can see on the screen of your device. In addition, the presentation includes user experience (UX) decisions that represent features available and how a user can interact with them.
Even though these layers are the major components of mobile application architecture, our iOS Team Lead notes that it’s fine to decompose any layer into smaller pieces to make testing easier and the process of developing a mobile app faster. In fact, it all depends on the type of mobile app you’re going to build.
Okay, we are done with how a mobile architecture should be assembled, and what are the main building blocks. Now, we need to touch upon the ways these blocks connect to each other.
And then patterns
There are tons of mobile app architecture patterns, according to which you can get all three layers together. Before we start discussing them, we’d like you to hear what our iOS Team Lead says about patterns: “Every single pattern is worth attention. Each pattern is good for a particular type of application, so we need to make a choice according to the goals of our project. Patterns are used to ensure that the development process is planned properly and we can achieve the project’s goals fast enough”.
That’s why when you choose a pattern to follow, you need to think whether it’s the fastest way for your mobile team to build the application. Besides, when all team members are familiar with the pattern, they’ll spend less time on writing documentation and designing tests.
On the latter front, creating proper tests is essential for long-term projects, which is why handpicking a pattern that is clear to everyone is so important for the entire mobile app architecture. With this being said, we can proceed with describing each pattern in detail.
This pattern is the most common one because it separates UI from business logic and data access layers. In such a way, you have a three-parts pattern: Model, Viewer, Controller.
Model holds the data and determines the rules according to which it will commute throughout the application. As for view, it relates to the presentation layer, where it builds upon the model because it takes the data from there. Eventually, the controller is a communicator between the model and the viewer. When a user sends a particular request, the controller can change the model to get the necessary data and bring it to the viewer.
This pattern is exceptionally good for apps that need to perform several functions at the same time without overlapping the data. Therefore, it’s much easier to change or entirely refactor the app code when necessary.
Nevertheless, the viewer doesn’t work well on iOS platforms, as a strong interconnection between the viewer and controller makes code maintenance and testing very hard, thereby creating more room for human error.
For starters, don’t confuse it with minimum viable product. In fact, in this case MVP stands for Model-Viewer-Presenter. While the roles of model and viewer are the same as in MVC, the presenter is slightly different from the controller.
Presenter focuses on querying the requests from the viewer’s side to model, and then directing the response back to the viewer. In this pattern, the presenter isn’t a connecting link but some kind of command outpost that coordinates the work of model and viewer.
The Model-View-ViewModel pattern is an upgrade of two previous patterns. The view and model perform the same roles, but this pattern also involves an element called viewmodel that is a mediator between the viewer and the model. The main perk of this pattern is that UI is separated from the business logic code, as long as UI is stored within the viewmodel that is responsible for presentation logic only.
An entirely different approach is taken by the View-Interactor-Presenter-Entity-Router pattern. Let’s review each element:
- View. It delivers a user’s request to the presenter.
- Interactor. This element holds the business logic.
- Presenter. The view logic is stored here and prepared for display.
- Entity. It is a part of the pattern that involves the model’s object that will be used with the interactor.
- Router. This is a separate element that is responsible for navigation logic.
VIPER pattern is particularly good for long-term projects as it doesn’t bring any mess when more features are added to the application. At the same time, there’s not much use of this pattern for simple and short-term projects. If you choose VIPER, you should be able to justify this choice well enough, otherwise it will be a burden rather than a helping hand.
Router-Interactor-Builder pattern is an exceptional way of getting mobile application architecture together, as it approaches business logic as the architecture’s centerpiece. While router and interactor perform the same roles as in VIPER pattern, builder is an individual component that puts router and interactor together.
The pattern was pioneered by Uber, so you can see what is the main idea behind bringing business logic into a sharp focus: the app both serves the customers and makes the business running. In other words, a user’s request is not only a subject to viewing a particular action on a screen, but also handling operations on the business side of the app.
Even though Flux pattern is invented for Facebook user-side architecture, sometimes it’s used in mobile apps, when the application should deliver the data in one direction: just to the user and nothing back. The pattern involves such elements as:
- Action. Action means action here. It’s a user’s request to perform some task within the app. For example, it can be a task to create a new page in a notes application.
- Dispatcher. The only thing this component does is delivery of action to the store. That’s it.
- Store. The data and logic of the whole app are stored here.
- View. This is the final stage of the data path, and it’s already known to us as a UI presentation. If we take the example with the notes app, the user sees that the new page is created as they requested.
This architecture pattern perfectly serves the simplification of developing a mobile app. The pattern involves such elements as model, view, and update. Again, we already know what model and view are expected to do, while update is needed to change the state of model depending on what user request is sent via the view element.
The cycle is simple: a user clicks a button, the model gets a task, the update changes the model’s state and sends the result back to the view. As a result, a user sees the response on their device screen.
Apart from simplicity, this architecture is good for applications with plain yet interactive functions, while a user can perform multiple actions. Games, in fact, are the most common example of relatable apps.
Once JatApp always strives for adopting the most prominent technologies for mobile software development and using the maximum creativity, our mobile development teams have their own vision of mobile application architecture. JatApp teams use two patterns: MVP + clean architecture and MVVM + Combine.
You’re already familiar with MVP architecture, but what does this “clean” thing mean? As a matter of fact, the main advantage of MVP + clean architecture is that the business logic is located in the presentation layer, so the presenter works both for handling the basic operations and displaying them within the user interface.
By using this architecture, JatApp iOS team developed a native iOS application 2BeAdventurous for our UK customer. Even though the app was just published on the AppStore, it has already got positive feedback, and the client’s business is ready to keep scaling it further.
2BeAdventerous user interface
As for MVVM + Combine, we need to mention that Combine is a framework for implementing MVVM architecture. The main idea of this framework is to unify and simplify the code for managing notifications, callbacks, and many other basic aspects of mobile application.
JatApp mobile development team used this architecture for Lily Plant, a plant recognition app. Due to our approach to the app’s architecture, our team managed to create the app powered with the artificial intelligence and advanced UI/UX design that is far superior than similar products on the market.
AI plant recognition in Lily Plant
Nonetheless, our mobile development teams don’t stop learning, which is why they are currently adopting the use of Reactive MVVM pattern to improve responsiveness and speed of operations in apps our teams work on.
JatApp can help you build architecture for your mobile app
Congratulations, we’ve broken down the concept of mobile application architecture into small pieces and you finally know what it is! With the knowledge about the mobile app architecture, you can be more confident about your project. Still, you need people who can actually work with your app’s architecture and select the best way to compose it.
In this regard, JatApp can offer its mobile development services. We have completed over 100 successful mobile projects, and 99% of our customers were satisfied with the apps we delivered to them.
Leave us a note to start your mobile project with JatApp. We’ll get back to you as soon as possible.