Six most critical Architecture Patterns.

ยท

2 min read

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:

Image

Thank you for your time and see you in the next.

Credits to Techworld with milan @milan_milanovic on X(Formerly Twitter)

ย