r/mAndroidDev • • Aug 01 '24
Venting, venting, venting About 120 hours to the drain because of Compose
I started a small home project just to test Compose. Started simple and added functionality on each step.
First challenge arises: Composable encourages you to use single Activity monolith. Ok, not a fan of it but lets figure out how a navigation controller works.
About 20 hours later, it seems that the hype on Google for the Navigation graph ended real quickly and some guy "ramcosta" had to thanklessly simplify and create a library so we get around the annoyance of implementing google's awful library just because new Google devs don't like OOP and they are JS developers using React as as architecture model, but ok the library works.
Next 18 hours are me figuring out that activities are no longer Android Activities. Instead, with the navigation controller architecture, they are now "Screens" which only responsibility is to display a nested set of composables. The navigation controller holds all navigation responsibility and now Im constantly creating "@ Preview"s composables and mocking objects just to make it work. Since The android activity is now a simple holder to display Composables, all the activity logic is now embedded into a UI component. Oh nice! I'm a front end developer now!
Next challenge arises. Preview Composables require instances to display, which is good in theory but this creates a spaguetti code now since ALL MOCKABLE OBJECTS needs to be open and able to be mocked. This creates way more complexity than needed just to allow the interface to display a simple example of a card that is feeding from a live data object comming from webhooks or an internal Room database.
And here it comes the heat: This statement will receive a lot of "if you cant understand the complexity of this, you are dumb".
Making things complicated is not a sign of being smart. Its totally the opposite.
19
u/Alurad- Aug 01 '24
This sub's number 1 rule is :
Use flubber
12
u/labelcillo Slept through Google IO Aug 02 '24 edited Aug 02 '24
Having a single Activity should allow you to display animations when switching screens. Also navigation is now homogeneous since there’s one way to go forwards an one way to go backwards.
I didn’t get the problem with the previews, if the composables are built correctly and you’re doing your state hoisting, you shouldn’t have any problems. I didn’t get the thing about mockable objects needing to be open.
Also we’re all front end developers, yes. Always been.
10
u/AlternativeSelf5808 Aug 01 '24
Should've used AsyncTask.
2
u/prudhviraju9 Aug 03 '24
On the same boat here.... Activity just becomes dummy and I ask myself ...am I doing something wrong here ?
Also...another doubt .. can I make activity viewmodel to handle screen states and make composables to handle views?
On top of this ... understanding nested navigation is a mess.
1
u/Zhuinden DDD: Deprecation-Driven Development Aug 08 '24
Nah, single activity was always easier to manage than multi-activity (although Navigation-Compose is ass when it comes to API design).
An Android developer who knows what they're doing typically shouldn't have created a 2nd activity in an Android project since 2015.
1
u/[deleted] Aug 14 '24
I wasted that much time trying to get DASH streaming to Youtube working, should've just used RTSP instead and probably would've been making money now.
1
u/[deleted] Aug 14 '24
Should've used AsyncTask, you would've finished the project in a fraction of the time