3 ms·
[ANDROID VERSION] Architecture: MVVM > MVP, MVC (aka none), MVI >>> "clean architecture" Strong preference here. You split the app into UI (View), UI logic (V
by muzani 3y ago
[ANDROID VERSION]
Architecture: MVVM > MVP, MVC (aka none), MVI >>> "clean architecture"
Strong preference here. You split the app into UI (View), UI logic (ViewModel) and Domain+Data (Model). UI handles how its seen and interacted with. Logic is handled in its own domain but you should pass minimal data to the UI and let it figure that out. Models are probably the most important to decouple, lets you switch from local, cache, or network data sources seamlessly.
Everything else is a mess. MVI is interesting but outdated. MVC is too tightly coupled that you can't do anything, not for tests or whatever. MVP is unnecessarily coupled. "Clean" is far too decoupled that it easily evolves into a monolith when a few hacks come in.
Observables: Flow > LiveData, RxJava, none
Flow is simpler and easier to mass adopt than RxJava. It does the same. It combos very, very, very nicely into Compose, which is where the winning advantage is. The others are not bad, but basically Flow lets you treat encapsulate the logic within the variables themselves, rather than dotting the whole code with if/else statements.
UI: Compose > classic XML >> data binding XML
Data binding absolutely sucks in production. It adds MINUTES to build time. Doubly sucks because with UI you're usually doing things like tweaking text, color, padding, and you want those fast iterations.
Compose's killer feature is getting rid of adapters, which can account for half of the development time in some places. Since everything in modern apps is a list. You no longer have to think about optimizing it, you just tell it to cache if you need it cached, then think about how to display it. And like data binding, you can encapsulate how data is displayed into the UI component itself. So you just pass something like state=ACTIVE to the UI and it decides what it wants to look like without you having to pass things like color.