Features of a good app architecture.
Separation of concerns. This principle means that different entities should be separated in the code. It helps with reusing those entities, systematizing development, easy debugging, and isolating frequently changing parts so they don’t affect others.
Testability. With appropriate architecture, it is way easier. QAs will find it helpful to write test cases and be able to test functionalities separately. You will avoid finding issues in runtime, which usually means a week-long fix.
Reliability. A well-chosen architecture is crucial to creating stable apps without major inconsistencies because it defines how parts of code interact with each other.
Scalability. Your app should have a solid basis for the buildup of new features and changes according to business needs. It also should be suitable for future renovations (e. g., new libraries, operating systems) in programming technologies.
Maintainability and ease of use. A good architecture simplifies code for both writing and reading. It can also result in a low maintenance cost.
MVC
The Model-View-Controller (MVC) is a well-known design pattern in the web development field. It is way to organize our code. It specifies that a program or application shall consist of data model, presentation information and control information. The MVC pattern needs all these components to be separated as different objects.
Model
It represents the business layer of application. It is an object to carry the data that can also contain the logic to update controller if data is changed.
View
It represents the presentation layer of application. It is used to visualize the data that the model contains.
Controller
It works on both the model and view. It is used to manage the flow of application, i.e. data flow in the model object and to update the view whenever data is changed.
MVVM
Every good developer wants and tries to create the most sophisticated applications to delight their users. Most of the times, developers achieve this on the first release of the application. However, with new feature addition, fixing the bug without putting a lot of consideration into the structure of the application code becomes difficult due to code complexity. For this, there is a need for good clean structure of code.
MVP
MVP pattern overcomes these challenges of MVC and provides an easy way to structure the project codes. The reason why MVP is widely accepted is that it provides modularity, testability, and a more clean and maintainable codebase. It is composed of the following three components:
Model
Layer for storing data. It is responsible for handling the domain logic(real-world business rules) and communication with the database and network layers.
View
UI(User Interface) layer. It provides the visualization of the data and keep a track of the user’s action in order to notify the Presenter.
Presenter
Fetch the data from the model and applies the UI logic to decide what to display. It manages the state of the View and takes actions according to the user’s input notification from the View.