Architecture of Mobile Applications
1. Definition and Importance
1.4. DESIGN PATTERNS IN MOBILE APP DEVELOPMENT/ CORE ARCHITECTURAL PATTERN
1. Layered Architecture (as a pattern): This pattern reinforces the strict hierarchical interaction between layers. Each layer only interacts with the layers immediately above and below it. Imagine a cake with distinct layers. Each layer has a specific role. The top layer (presentation) interacts with the user, the middle layers handle business logic, and the bottom layer interacts with the database. While simple, it can become rigid and difficult to change if layers become tightly coupled.
2. Microservices Architecture: In the context of layers, microservices can be seen as independently deployable units that implement specific parts of the business logic layer. Each microservice might have its own data access and storage layers. Think of a city with independent specialized departments (services). Each department handles a specific task (e.g., user accounts, payments). They communicate with each other through well-defined interfaces. This allows for independent scaling and development.
3. Event-Driven Architecture: Events can occur at any layer. The presentation layer might trigger an event (e.g., button click), which is then handled by the business logic layer. Like a town square where announcements (events) are made. Different departments (components) listen for relevant announcements and react accordingly. This is great for real-time updates and asynchronous communication
4. Client-Server Architecture: The client (mobile app) typically encompasses the presentation, business logic, and data access layers. The server handles the data storage and potentially some business logic. A restaurant analogy. The customer (client) orders food (requests data) from the waiter (server). The server processes the request and delivers the food. This is common for apps that rely on remote data and services.
5. Model-View-Controller (MVC): A play with three roles. The Model represents the data and business logic (the script), the View is what the audience sees (the stage), and the Controller is the director who takes user input and updates the Model and View. Use Case: Simple apps (e.g., calculator).