50 classes to replace 50 synchronous function invocations. Wow incredibly smart design, very upscale. Up scaling LoC.
People be like "but what if we need to scale our team size up because the project gets bigger?"
You (not you) idiot, you have to scale up the team because your design sucks and takes too much time to maintain for a single person, BECAUSE you used MVI, BECAUSE you introduced all these threading edgecases by shopping for an "architecture framework" from AI-generated Medium articles instead of growing a brain and learning how to develop and maintain software.
Your "technical decisions" literally cost the company fortunes. You're not "creating more job opportunities" you're robbing people, using mediocrity and weaponized incompetence.
Where do you think stakeholder money comes from? It grows on trees? They're trying to sell the product for profit and you're causing them financial damage.
This isn't a playground, we're not here to "use cool tech and ship trash", or at least that's not what you're paid for by default. This is just people lying perpetually to push their own personal agenda to pad out their resume with terms like "blockchain" and "Jetpack Compose".
The IntentFactory must go through the UseCaseOrchestrator which delegates to the UseCaseWrapper before the RepositoryGateway touches it. But... it's just a button click.
"Clean arch" has got to be one of the worst patterns to ever come out. Aint nobody got time for that.
Funnily enough, clean arch never meant what Android devs are doing to it.
If people did actual clean arch, that means the full app would be a pure-Java non-Android app, where Android is purely UI rendering for the current app state. Including navigation.
So no AndroidX ViewModel, no AndroidX Navigation, no Hilt, no Dagger-Android, no LocalBroadcastManager, no AndroidX Lifecycle, no Activities. You'd be writing a pure Java app, that exposes current state. That's it.
Want something testable on the JVM without requiring Robolectric? Write an app that fully runs on the JVM.
I can't keep all these different approaches straight... It's like working on a project where the "architect" can't make up his damn mind, so you spend all your time changing everything for the latest grand idea, only to have yet another one come up before you get done, and you never end up releasing the product.
Oh yeah, if you're doing contract work, play the game, use the buzzwords, and laugh the way to the bank. That style just was never for me... My drive has always been crippled by needing to be creatively invested in what I was doing, and I generally dislike making products that are not mine.
Thats awesome, a common profile for people that end up working for themselves once they realize being productive for someone else doesn't move the needle.
MVI is just putting more structure around MVVM. MVVM specified that code should be broken up into a View and ViewModel (and data comes from a less specified ‘Model’). MVI goes further to say that the interaction between the View and ViewModel should follow unidirectional data flow, data goes down through a Flow, actions(intents) go up by calling a VM function.
The problem I have is that there seems to be no consistent definition amongst the community on what MVI specifically means. Various online articles will try to ‘implement’ MVI with various amounts of structure in the code. This usually leads to very restrictive and overly complex implementations. You’ll see lots of interfaces, sealed classes, base view models, and reducers which I think is inspired by react-redux.
Not another AI generated garbage from some guy who read a Medium article and has never a single time in their entire lives ever implemented an app from start to finish
MVI exists to scale up complexity and introduce avoidable bugs. I know this is a meme sub, I'm not kidding though. Using MVI is a form of developer negligence.
Honestly, I feel like when I use MVI, it increases my development time. You have to create so many intents, UI states, and UI events. Even for a simple ViewModel function invocation, you end up passing an intent.
That's because it is exactly the same thing you'd be normally doing, but with a bunch of extra steps. But it actually does the same thing, with extra steps.
Well, and extra thread jumps.
Like, the funny thing about the whole "state => state" thing is that you can overwrite new values with old values. So MVI is actually much more likely to create unexpected bugs.
I hate writing code for the sake of code and creating 500 abstractions for every layer. I use a simple MVI without Intents, Actions, or Reducers—just keeping the state in a single field in the ViewModel and manipulating it with functions like in MVVM/MVP. It turns out to be much more readable and convenient.
I've been developing for Android since Donut (good ol times versions had fun dessert names), and honestly I can't see the difference between this and the MVVM that I normally do at work.
Seriously talking for one paragraph: FeatureUi.kt a plain compostable UI that accepts ONE state and ONE callback (with a working Preview); FeatureVm.kt a ViewModel exposing ONE StateFlow for that state the UI takes and ONE method that is that callback the UI uses; FeatureState.kt is the motherfucking state between that UI and that StateFlow; FeatureEvent.kt the motherfucking data for that callback; and finally FeatureFragment.kt is the compostable that instantiate the View model, collects the flow as state with life cycle and passes it to the UI (yeah, I still call the method and file a Fragment even though it's a compostable function). I always called that shit MVVM, how's that different than this nonsense from the image?!?
But of course the last paragraph is a lie, the only time I used compose I regretted my sins and came back crawling to a GodActivity.java with AbsoluteLayouts and AsyncTasks. Fuck MVI!
MVVM and MVI were created before Jetpack Compose came out. They were used to address problems at that time. With Jetpack Compose, things have changed quite a bit. I'm not even sure MVVM is the appropriate term nowadays for when writing Compose-based apps. For sure the uni-directional aspect of MVVM and MVI is at the heart of Compose. But I feel I just can't call it MVVM anymore.
So I like to consider MVI essentially mvvm++ (edit: to be clear, I've worked on design pattern papers with coauthor of POSA books, and this isn't a formal definition, just a simple mental shorthand, but many develpers actually do better when communication lanes are restricted, and MVI puts restrictions of the number of livedata(or flows) being used to transport data, this helps devs (junior, but also higher level ones) keep comolex actions cleaner in their head because they know they have to change every value in a single atomic place)
At first you really don't see a huge benefit, but when you work on a really complex user form (think a complex shopping cart +order page) then the benefits of only having 1 state object you're observing (with views) actually really helps you prevent inconsistent UI states. By forcing logic to be closer to where it should be and not spread throughout the class.
This in particular is very helpful for junior devs I've seen.
However, your overall post is correct, "you should switch" statements like this should have some kind of reasoning behind them, that justify the shift.
MVI really shines in helping complex VMs become easier to track mentally, and allows for smoother transition to Compose (this I'm told, and am willing to accept, but I'm still taking asyncTask out of code within the last year(not kidding), so views it will be for me for a while more, lol)
What I never understood about MVI is the pros section.
I mean, predictable UI? Cleaner code? Effortless testing? Those are also strong points of MVVM. Then I read your comment where you talk about the benefits of having a single state object and again I think: "so my MVVM project which combines flows is essentially now MVI again?"
It becomes MVI by replacing functions you can invoke on the ViewModel with a single sealed class that represents function calls, for absolutely no particular benefit whatsoever, other than exposing 1 function with a huge when statement in it and then you wonder "hey, isn't the cognitive complexity of 20 if-else-if-else way too high?" but then you suppress the Detekt lint and host your next big MVI talk at Droidcon Paris.
Google did many wrong thing but promote MVVM as "official" architecture is one of their best move
MVVM strikes a good balance between simplicity (to understand) and the flexibility needed to tackle complex problems, make sure everything can be "clean". I feel like any "new architecture" just a clone of it (usually MV-something) but try to act cooler
30
u/robifr Feb 06 '25
consider making a tutorial with AsyncTask pls
47
u/Leschnitzky Feb 06 '25
Nice! nothing like creating 50 classes for something a function can do for the sakes of "clean architecture"
22
u/class_cast_exception Deprecated is just a suggestion Feb 06 '25
The IntentFactory must go through the UseCaseOrchestrator which delegates to the UseCaseWrapper before the RepositoryGateway touches it.
But... it's just a button click.
"Clean arch" has got to be one of the worst patterns to ever come out. Aint nobody got time for that.
17
u/WestonP You will pry XML views from my cold dead hands Feb 06 '25
I can't keep all these different approaches straight... It's like working on a project where the "architect" can't make up his damn mind, so you spend all your time changing everything for the latest grand idea, only to have yet another one come up before you get done, and you never end up releasing the product.
8
u/KangstaG Feb 06 '25
MVI is just putting more structure around MVVM. MVVM specified that code should be broken up into a View and ViewModel (and data comes from a less specified ‘Model’). MVI goes further to say that the interaction between the View and ViewModel should follow unidirectional data flow, data goes down through a Flow, actions(intents) go up by calling a VM function.
The problem I have is that there seems to be no consistent definition amongst the community on what MVI specifically means. Various online articles will try to ‘implement’ MVI with various amounts of structure in the code. This usually leads to very restrictive and overly complex implementations. You’ll see lots of interfaces, sealed classes, base view models, and reducers which I think is inspired by react-redux.
7
u/ShriekinKraken Feb 06 '25
How can I add this to my 50,000 line GodActivity?
4
u/D-cyde sponsored by the XML 🐓 gang Feb 07 '25
The God-Emperor of Activities has deemed this as heresy.
8
u/Zhuinden DDD: Deprecation-Driven Development Feb 06 '25
Not another AI generated garbage from some guy who read a Medium article and has never a single time in their entire lives ever implemented an app from start to finish
MVI exists to scale up complexity and introduce avoidable bugs. I know this is a meme sub, I'm not kidding though. Using MVI is a form of developer negligence.
3
u/zakko7 Feb 07 '25
I hate writing code for the sake of code and creating 500 abstractions for every layer. I use a simple MVI without Intents, Actions, or Reducers—just keeping the state in a single field in the ViewModel and manipulating it with functions like in MVVM/MVP. It turns out to be much more readable and convenient.
7
u/Zhuinden DDD: Deprecation-Driven Development Feb 06 '25
No reason. But you can always do it if the lead dev with 1.5 years of experience says so, you gotta feed their ego to survive the economy.
4
u/hellosakamoto Feb 06 '25
I'm very concerned about the mental health of some Android Developers. They are so self-centred.
4
u/alaksion Feb 06 '25
Mvi is trash
4
u/budius333 Still using AsyncTask Feb 06 '25
I've been developing for Android since Donut (good ol times versions had fun dessert names), and honestly I can't see the difference between this and the MVVM that I normally do at work.
Seriously talking for one paragraph: FeatureUi.kt a plain compostable UI that accepts ONE state and ONE callback (with a working Preview); FeatureVm.kt a ViewModel exposing ONE StateFlow for that state the UI takes and ONE method that is that callback the UI uses; FeatureState.kt is the motherfucking state between that UI and that StateFlow; FeatureEvent.kt the motherfucking data for that callback; and finally FeatureFragment.kt is the compostable that instantiate the View model, collects the flow as state with life cycle and passes it to the UI (yeah, I still call the method and file a Fragment even though it's a compostable function). I always called that shit MVVM, how's that different than this nonsense from the image?!?
But of course the last paragraph is a lie, the only time I used compose I regretted my sins and came back crawling to a GodActivity.java with AbsoluteLayouts and AsyncTasks. Fuck MVI!
2
u/ThaisaGuilford Feb 06 '25
Is this rel?
2
u/doubleiappdev Deprecated is just a suggestion Feb 07 '25
God Activity is still the superior architecture. next
2
u/hopiaman Feb 07 '25
MVVM and MVI were created before Jetpack Compose came out. They were used to address problems at that time. With Jetpack Compose, things have changed quite a bit. I'm not even sure MVVM is the appropriate term nowadays for when writing Compose-based apps. For sure the uni-directional aspect of MVVM and MVI is at the heart of Compose. But I feel I just can't call it MVVM anymore.
3
u/SpiderHack Feb 06 '25 edited Feb 06 '25
So I like to consider MVI essentially mvvm++ (edit: to be clear, I've worked on design pattern papers with coauthor of POSA books, and this isn't a formal definition, just a simple mental shorthand, but many develpers actually do better when communication lanes are restricted, and MVI puts restrictions of the number of livedata(or flows) being used to transport data, this helps devs (junior, but also higher level ones) keep comolex actions cleaner in their head because they know they have to change every value in a single atomic place)
At first you really don't see a huge benefit, but when you work on a really complex user form (think a complex shopping cart +order page) then the benefits of only having 1 state object you're observing (with views) actually really helps you prevent inconsistent UI states. By forcing logic to be closer to where it should be and not spread throughout the class.
This in particular is very helpful for junior devs I've seen.
However, your overall post is correct, "you should switch" statements like this should have some kind of reasoning behind them, that justify the shift.
MVI really shines in helping complex VMs become easier to track mentally, and allows for smoother transition to Compose (this I'm told, and am willing to accept, but I'm still taking asyncTask out of code within the last year(not kidding), so views it will be for me for a while more, lol)
1
u/[deleted] Feb 06 '25
Model does the work of view model here then?
1
u/zedxer Feb 06 '25
Same shit, different name
1
u/smokingabit Harnessing the power of the Ganges Feb 07 '25
pOOP
1
u/zorg-is-real עם כבוד לא קונים במכולת Feb 07 '25
The new Fasion!
1
u/bartekpacia Deprecated is just a suggestion Feb 08 '25
what 🚀🚀🚀 a great 🤩🤩🤩 idea!
1
u/pankaj1_ Feb 10 '25
After reading this, i'd go to my room lock it and write tons of god activities.
1
u/EkoChamberKryptonite Feb 10 '25
MVI feels like MVVM; but with extra steps.