Programming WTF: What does MODEL, STATE mean in MVP, MVVM, MVC, MVI Architecture?

preview_player
Показать описание
The other day I was chatting with a developer about how to do Model View Presenter, or MVP properly. I almost forgot my own difficulty with three layer architectures and the meaning of model, as I went through a similar amount of confusion understanding exactly what it means.

It turns out that the problem is that there is no exact definition for Model, with the exception that it should always have something to do with data storage and access. Beyond that, some developers use the term Model as just a synonym for "back-end" or database. While this is not technically in violation of the general definition, assuming this is what Model means will lead to confusion on application state which has nothing to do with the back-end.

Looking for a comprehensive introduction to Kotlin, Android, and Programming in general? If so, consider picking up my introductory course to Programming Fundamentals with Kotlin and Android on Udemy; I don't think you'll be disappointed:
Рекомендации по теме
Комментарии
Автор

I'd prefer better the following explanation because persistence is not mandatory, to be honest:
MV* pattern family is created to do one job: create modular programs which are decoupled from how they look. That way logic that it was written, for instance, a smart watch 1, could be reused for something else. Smart watch 2, Smart watch 3, you name it. It also helps in understanding the code. That way code can evolve (that is a crucial part). No program is written all at once, it is always an iterable approach.


A real-world example from CMS: a logic that is written to serve regular users some video is reused for "preview" feature button for admins.

So, a model is a part of your program that is agnostic about how it looks like. Pure algorithms (even dumb ones). It must contribute to the main purpose of a program in some sense, otherwise one could name a dependent library as part of some model.

snowy
Автор

You really look like Bjorn from Vikings series xD
Great tutorial, by the way

Shredder
Автор

Great, so see if i'm getting this right:
A "Model" Is for storage/access of state data of any architectural layer. The front end/UI-layer might have its state stored (modeled) by some “UI Model” class. The data layer might have its state stored (modeled) by some “Data Model” class like “User” or “UserAccount”. Such a "User" or "UserAccount" class encapsulates real world user info.
How far off am i?

gdk
Автор

what is a Data Model and UI model?? went 10 feet over my head....

pembatamang
Автор

brother do android developers need to learn solid principles?

muraddadasov