Six most critical Architecture Patterns.
There are several Architectural patterns widely in use. However, six of them are quite common and critical, and it is for a good reason. Below are the patterns, why you should use them, and when you should use them.
- Model View Controller(MVC).
This is one of the earliest and widely adopted Architecture patterns. Its primary goal is to separate the application's data, user interface, and control logic into three interconnected components.
The model manages data and logic, the view displays the information, and the controller connects the model and the view, handling user Input.
Usage: For web applications with a clear separation between data handling and UI.
- Model View Presenter(MVP).
This pattern evolved from MVC, aiming to address its shortcomings in event-driven environments by decoupling the view from the Model, with the presenter acting as the middleman. The model manages the data, view displays data, and sends user commands to the presenter, while the presenter retrieves data from the Model and presents it to the view.
Usage: Applications emphasizing testing and UI logic, such as in Android applications.
- Model View Intent(MVI).
This is a reactive architecture embracing unidirectional data flow, ensuring that, given a state, the UI remains consistent. The model represents the state, the View reflects the view state, while intent represents User interactions that change the state. It is widely used in Reactive applications or frameworks such as RxJava with a focus on state consistency.
- ๐ ๐ผ๐ฑ๐ฒ๐น-๐ฉ๐ถ๐ฒ๐-๐ฉ๐ถ๐ฒ๐๐ ๐ผ๐ฑ๐ฒ๐น(MVVM).
MVVM arose to address complexities in UI development, promoting a decoupled approach with the ViewModel handling view logic without knowing the UI components. The model in this scenario manages and displays data while the model holds and contains UI-related data. This model is highly suitable for UI-rich applications or platforms with data binding, such as WPF or Android with LiveData.
- ๐ ๐ฉ๐ฉ๐ ๐๐ถ๐๐ต ๐๐ผ๐ผ๐ฟ๐ฑ๐ถ๐ป๐ฎ๐๐ผ๐ฟ(๐ ๐ฉ๐ฉ๐ -๐).
This builds upon MVVM, introducing the Coordinator to handle navigation, decoupling it from View and ViewModel. This model is good for larger applications, especially IOS, where complex navigation needs separation from view logic.
- ๐ฉ๐ถ๐ฒ๐-๐๐ป๐๐ฒ๐ฟ๐ฎ๐ฐ๐๐ผ๐ฟ-๐ฃ๐ฟ๐ฒ๐๐ฒ๐ป๐๐ฒ๐ฟ-๐๐ป๐๐ถ๐๐-๐ฅ๐ผ๐๐๐ฒ๐ฟ(๐ฉ๐๐ฃ๐๐ฅ).
This is a modular architecture that is akin to Clean architecture. It emphasizes on testability and the single Responsibility Principle by breaking down application logic into distinct components. In this model, the view displays what the parameter sends, the interactor contains business logic per use case. The presenter contains view logic for preparing content, the entity includes a primary model object, and the router contains navigation logic. This model is good for complex applications, especially IOS, need modularity, testability, and clarity.
Below is an image summarizing that:
Thank you for your time and see you in the next.
Credits to Techworld with milan @milan_milanovic on X(Formerly Twitter)