Every Android team eventually holds the same meeting. One side wants the pattern called MVVM, the other wants MVI, and both cite Google. The meeting recurs, because neither side can produce the page that proves it. There is a reason for that.
The Vendor Names Neither
We checked. Google's architecture guide and its UI layer guide do not contain either acronym. What they recommend is two principles: give every piece of data one owner, and let state travel in one direction. In the guide's words, "only the SSOT can modify or mutate it", and "state flows in only one direction" (Android).
Our own article called one of these patterns official until this month. It was wrong, and it is corrected.
The Real Question Is Smaller
Strip away the names and the disagreement is one design choice: does a screen describe itself with one bundle of state, or with several independent ones? That question does have a published answer, and it is conditional: "The key guiding principle for choosing between exposing UI state in a single stream or in multiple streams is the relationship between the items emitted" (Android).
Related values belong together, because the benefit is consistency: "consumers of state always have the latest information available at any given time." Unrelated values can stay apart. A checkout, where the address changes the delivery options and the delivery options change the total, wants one bundle. A settings page does not need it.
Why This Matters Outside Engineering
The symptom of the wrong choice is visible to customers: a spinner and an error message on screen together, or a total that does not match the cart. Those are not random bugs. They are what happens when values that describe one situation are updated separately.
The cost of the debate is also real. A standard imposed on every screen forces ceremony onto simple ones, and a free-for-all leaves the complex ones fragile. The decision is per screen, and it takes minutes once the rule is known.
What to Ask Your Team
- Which screens have shown contradictory states in production? Those are the candidates for one state object.
- Is our architecture standard a rule or a preference? If it cites a vendor, ask for the page.
- Can one screen change approach without touching the others? It should be able to.
-Rocky
#SoftwareArchitecture #TechnicalLeadership #MobileEngineering #EngineeringDreams #StrategiaX
Originally published on ANDROID-ARCHITECT, the Android engineering blog of Strategia-X, with both patterns in code.
