# Gabor Varadi

Stories by Gabor Varadi on Medium

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Reclaim the reactivity of your state management, say no to imperative MVI

DevFeed: [Reclaim the reactivity of your state management, say no to imperative MVI](<https://devfeed.tech/articles/reclaim-the-reactivity-of-your-state-management-say-no-to-imperative-mvi-25932.md>)

Original publisher: [Read original article](<https://proandroiddev.com/reclaim-the-reactivity-of-your-state-management-say-no-to-imperative-mvi-3b23ca6b8537?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2022-05-02T05:05:46Z

Content type: opinion

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [state-management](<https://devfeed.tech/topics/state-management.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Redux](<https://devfeed.tech/topics/redux.md>), [Finite-state machine](<https://devfeed.tech/topics/finite-state-machine.md>), [Elm](<https://devfeed.tech/topics/elm.md>)

Tags: [2015](<https://devfeed.tech/tags/2015.md>), [2019](<https://devfeed.tech/tags/2019.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-pattern](<https://devfeed.tech/tags/architecture-pattern.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [clean-architecture](<https://devfeed.tech/tags/clean-architecture.md>), [clean-code](<https://devfeed.tech/tags/clean-code.md>), [command](<https://devfeed.tech/tags/command.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coupling](<https://devfeed.tech/tags/coupling.md>), [cyclomatic-complexity](<https://devfeed.tech/tags/cyclomatic-complexity.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [elm](<https://devfeed.tech/tags/elm.md>), [framework](<https://devfeed.tech/tags/framework.md>), [imperative](<https://devfeed.tech/tags/imperative.md>), [model-view-intent](<https://devfeed.tech/tags/model-view-intent.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [reactivity](<https://devfeed.tech/tags/reactivity.md>), [state](<https://devfeed.tech/tags/state.md>), [state-management](<https://devfeed.tech/tags/state-management.md>)

### AI overview

The author argues that imperative MVI makes UI state depend on sequentially reducing the previous state, which can force evaluation of every input and prevent ViewModel-level cancellation or debouncing. They trace this approach to command-processing patterns and criticize Android MVI frameworks for storing screen state in one serialized, mutable field. Their alternative is to derive state by combining reactive input flows with `combine` rather than `scan`, allowing debouncing, filtering, and asynchronous data loading while using the latest input values. The text presents this as a way to avoid reducer boilerplate and support process-death persistence, while framing its criticisms as the author's perspective.

### Source excerpt

Do you find yourself chasing for "clean code, clean architecture, clean design, clean state management" yet still feel bogged down in a sea of boilerplate for even the simplest of tasks -- such as showing a simple list fetched with a coroutine? Surely this could be done in a single line or maybe about seven, but it certainly shouldn't need gigantic case-whens, three layers of indirection, and so on? Well, normally you could just invoke functions on ViewModel and it would work, but if you're forced to seek the "architectural holy grail", no one around you will trust your code unless you add at least one sealed class called ViewActions, and increase the cyclomatic complexity of your "action handler" function until it feels "just clean enough". (After all, surely the more completely unrelated things a single function does based on its argument, the more it has a "single responsibility" of handling literally everything, which is why you know it's definitely the best possible way to do it. 😏) Anyway, the boilerplate of coupling together all aspects into a single class, whether it is a function call or state property, this all has a history: namely, it came from the web. The brief history of MVI MVI stands for "model-view-intent" and comes from a (not very popular for use in production) Javascript framework called Cycle.js, hand-in-hand with a (not popular anymore) concept called "The Elm Architecture" defined as the best practices and intended use of an experimental (and since 2019, unmaintained) "functional-reactive programming language for the web" called ELM. Then again, these didn't come from a vacuum either -- the originator is Redux, in 2015. The general idea was to implement a state machine using the command processor pattern in Javascript, thereby supporting "undo" functionality (also often referred to as "time-travel debugging"). Of course, most design decisions of Redux only make sense for Javascript -- as it is a language with no static typing. It makes sense to

## Simplified navigation between Composables of Jetpack Compose using Simple-Stack

DevFeed: [Simplified navigation between Composables of Jetpack Compose using Simple-Stack](<https://devfeed.tech/articles/simplified-navigation-between-composables-of-jetpack-compose-using-simple-stack-25936.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/simplified-navigation-between-composables-of-jetpack-compose-using-simple-stack-9a796a909128?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-03-09T15:10:09Z

Content type: tutorial

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [android-jetpack-compose](<https://devfeed.tech/tags/android-jetpack-compose.md>), [compose](<https://devfeed.tech/tags/compose.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>), [state](<https://devfeed.tech/tags/state.md>), [state-management](<https://devfeed.tech/tags/state-management.md>)

### AI overview

This tutorial explains how to use Simple-Stack's Compose integration for navigation between Jetpack Compose screens. It covers dependency and Activity setup, key classes, backstack navigation, configuration-change data storage, scoped services, lifecycle callbacks, and state persistence. The integration is described as beta.

### Source excerpt

Have you ever wanted to navigate between two Composables? Do you wish it were as easy as backstack.goTo(SomeScreen(arg1, arg2)) and you would go there? Good news, because now that seems to be possible with Simple-Stack's Compose integration -- which I consider BETA for now, but nonetheless, it's possible. What it looks likeInitial setup and dependencies: First, you would add the dependencies: implementation 'com.github.Zhuinden:simple-stack:2.6.0' implementation 'com.github.Zhuinden:simple-stack-extensions:2.2.0' implementation 'com.github.Zhuinden:simple-stack-compose-integration:0.2.0' And of course, you'd add Jitpack (not JCenter): // build.gradle allprojects { repositories { // ... maven { url "https://jitpack.io" } } // ... } And most importantly, you'd enable Compose: compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' useIR = true } buildFeatures { compose true }Setup To use Simple-Stack within an Activity, we use the Navigator, as always. The Compose integration is merely a different implementation of StateChanger, along with a helper that allows exposing the Backstack as a CompositionLocal for children within the composable tree. class MainActivity : AppCompatActivity() { private val composeStateChanger = AnimatingComposeStateChanger() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val backstack = Navigator.configure() .setScopedServices(DefaultServiceProvider()) .setStateChanger(AsyncStateChanger(composeStateChanger)) .install(this, androidContentFrame, History.of(FirstKey())) setContent { BackstackProvider(backstack) { MaterialTheme { Box(Modifier.fillMaxSize()) { composeStateChanger.RenderScreen() } } } } } override fun onBackPressed() { if (!Navigator.onBackPressed(this)) { super.onBackPressed() } } } This implementation of StateChanger is able to switch between keys that extend from DefaultComposeKey. In the samples, I genera

## Creating a BottomNavigation Multi-Stack using Child Fragments with Jetpack Navigation

DevFeed: [Creating a BottomNavigation Multi-Stack using Child Fragments with Jetpack Navigation](<https://devfeed.tech/articles/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-jetpack-navigation-25934.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-jetpack-navigation-5d4c24ea6f4f?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-26T06:14:32Z

Content type: tutorial

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [jetpack-navigation](<https://devfeed.tech/topics/jetpack-navigation.md>), [bottom-navigation](<https://devfeed.tech/topics/bottom-navigation.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [bottom-navigation](<https://devfeed.tech/tags/bottom-navigation.md>), [bottomnavigationview](<https://devfeed.tech/tags/bottomnavigationview.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [graph](<https://devfeed.tech/tags/graph.md>), [history](<https://devfeed.tech/tags/history.md>), [jetpack-navigation](<https://devfeed.tech/tags/jetpack-navigation.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [navigation-component](<https://devfeed.tech/tags/navigation-component.md>), [stack](<https://devfeed.tech/tags/stack.md>)

### AI overview

The excerpt describes hosting a bottom navigation view inside a parent fragment while maintaining a separate Jetpack Navigation back stack for each tab. The parent adds all tab fragments to keep them alive, then detaches hidden tabs and attaches the active one so only it remains active. For each tab, the approach creates a fragment host with its own NavController and navigation graph, supplied as an argument; the excerpt cuts off before detailing navigation within those child stacks.

### Source excerpt

It's been a recurring question, regardless of navigation framework of choice: how is it possible to create a screen with a bottom navigation view, that would host a navigation history stack per each tab? Each framework has its own unique ways. For example, with Jetpack Navigation you might use the NavigationExtensions, which requires you to host the BottomNavigationView at the Activity-level. But how would you do it with Jetpack Navigation, in such a way that the BottomNavigationView is confined to a single child fragment, and that child fragment would host all tabs that each have a NavController (backstack) available to them? How bottom navigation with child fragments normally works If you intend to create a BottomNavigationView that is hosted by a Fragment (and that Fragment hosts each tab as a child fragment), there's a bit of work needed to be done. To keep the fragments alive while switching between them, they must all be added. However, to make sure that the fragments are in the correct lifecycle (stopped while not showing), it makes sense to detach them (and attach the one that is meant to be showing). https://medium.com/media/82eb957284cfe5def31160ac33d277ba/href This example is also available here. Please note that there is nothing specific to Jetpack Navigation in this snippet, this is how a fragment can manage its child fragments and keep only one of them attached, while the rest are detached. We will use this knowledge later in the article. What Jetpack Navigation normally does When you use Jetpack Navigation (using its XML-based DSL) you typically create a navigation.xml (typically 1 per compilation module, but multiple nav graphs + include can be used too), which is then given to a NavHostFragment in a FragmentContainerView. This is what allows the NavController to be initialized with a graph, and save/restore its state. https://medium.com/media/4cc60fc3c96786f7f9adcbb3a1053853/hrefCreating a NavController and backstack for each bottom navigation tab T

## An opinionated guide on how to make your Kotlin code fun to read and joy to work with

DevFeed: [An opinionated guide on how to make your Kotlin code fun to read and joy to work with](<https://devfeed.tech/articles/an-opinionated-guide-on-how-to-make-your-kotlin-code-fun-to-read-and-joy-to-work-with-25931.md>)

Original publisher: [Read original article](<https://proandroiddev.com/an-opinionated-guide-on-how-to-make-your-kotlin-code-fun-to-read-and-joy-to-work-with-caa3a4036f9e?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-15T06:16:05Z

Content type: tutorial

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Code quality](<https://devfeed.tech/topics/code-quality.md>), [scope function](<https://devfeed.tech/topics/scope-function.md>), [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>), [conditionals](<https://devfeed.tech/topics/conditionals.md>), [if statement](<https://devfeed.tech/topics/if-statement.md>), [code beautification](<https://devfeed.tech/topics/code-beautification.md>), [pretty printing](<https://devfeed.tech/topics/pretty-printing.md>), [smart cast](<https://devfeed.tech/topics/smart-cast.md>), [constructor](<https://devfeed.tech/topics/constructor.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [code-style](<https://devfeed.tech/tags/code-style.md>), [guide](<https://devfeed.tech/tags/guide.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [style](<https://devfeed.tech/tags/style.md>)

### AI overview

The guide favors Kotlin code whose intent and types stay easy to read as code evolves. Put constructor properties on separate lines when there are multiple arguments, use named lambda parameters in multi-line or chained expressions, and name multiple callback lambdas. Reserve `let` for simple assignments or returns; avoid using it as general control flow or replacing `if`/`else` with `x?.let {} ?: run {}`. Prefer early returns with the Elvis operator when there is no alternate branch, explicit return types on public non-override functions, `val` where mutation is unnecessary, and non-null parameters when null is not meaningful. Use named data classes rather than positional decomposition or tuple return types when fields carry distinct meanings. The author also recommends read-only `List` types instead of exposing mutable list types, built-in collection operations instead of equivalent loops, and choosing function types, `fun interface`, or regular interfaces according to whether callbacks need a name or multiple methods. These are presented as style recommendations, with some preferences explicitly personal or situational.

### Source excerpt

I've been meaning to write this article in a while. Hopefully, the following tips and style recommendations (in no particular order) will help you write better Kotlin! Let's get on with it, shall we? For 2 or more constructor arguments, prefer not to keep the properties on the same line as the class name in the constructor definitionclass MyClass( val a: A, val b: B, ): MyParentClass(a, b), MyInterface { // ... } This format is preferable, because when adding the 3rd argument, important bits (such as a possible base class or interface) can appear too far on the right side of the screen. Listing them one after the other (including the trailing comma since 1.4.21+) allows for better readability and extensibility (reducing the chance of causing merge conflicts with future code changes, for example). Prefer to use the scoping function 'let' only in assignments or return statements, but NOT as general control flow, or a "quick rename to 'it'" Oftentimes, Kotlin code tends to do something like this: fun myMethod(nullableA: A?) { nullableA?.let { // no it.x() // no it.y() // no it.z() // no } } (Note: in a method like this, A? could be replaced with A to take advantage of typed nullability, this is just an example.) To allow better maintainability and readability, we should instead prefer to only use ?.let { in simple assignments, or return statements, but not as general control flow. For example, the following chain is easy to understand: val protoClass = savedInstanceState?.getByteArray("protoValue") ?.let { ProtoClass.parseFrom(it) } However, in this case, ?.let { is part of an assignment. Also, while ?.let { can be chained with a ?: to provide a default value (especially in combination with takeIf) it shouldn't be used to execute side-effects (also is more suitable for that). In fact, it needs to be said: x?.let {} ?: run {} is NOT a general purpose replacement for if-else statements and null-checks, and should never be used in this particular format for that purpose!

## Dagger Tips: Guide to using Dagger-Android effectively

DevFeed: [Dagger Tips: Guide to using Dagger-Android effectively](<https://devfeed.tech/articles/dagger-tips-guide-to-using-dagger-android-effectively-25929.md>)

Original publisher: [Read original article](<https://itnext.io/dagger-tips-guide-to-using-dagger-android-effectively-c3e5b2883b38?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-02-13T05:05:50Z

Content type: article

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Dagger](<https://devfeed.tech/topics/dagger.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [dagger-hilt](<https://devfeed.tech/topics/dagger-hilt.md>), [software-architecture](<https://devfeed.tech/topics/software-architecture.md>), [software-development](<https://devfeed.tech/topics/software-development.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dagger-2](<https://devfeed.tech/tags/dagger-2.md>), [dagger-android](<https://devfeed.tech/tags/dagger-android.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [hilt](<https://devfeed.tech/tags/hilt.md>), [modularization](<https://devfeed.tech/tags/modularization.md>), [module](<https://devfeed.tech/tags/module.md>), [scalability](<https://devfeed.tech/tags/scalability.md>), [type-safe](<https://devfeed.tech/tags/type-safe.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>), [worker](<https://devfeed.tech/tags/worker.md>)

### AI overview

Dagger-Android uses map multibinding to dispatch field injection when feature modules cannot call inject on an application component directly. With AndroidInjectionModule and @ContributesAndroidInjector, Dagger generates injector factories; DispatchingAndroidInjector looks up a factory by the target class, creates an injector, and injects the instance. For maintainability, the excerpt recommends defining a module per screen, aggregating screen modules within each feature module, then including feature aggregates in the app component, instead of collecting all screens in global activity, fragment, and ViewModel modules. Dagger-Android is superseded by Hilt, which handles common Android types through @AndroidEntryPoint, @HiltViewModel, and @HiltWorker; the article frames Dagger-Android's dynamic injection as mainly useful for legacy or modularized cases. The text is an excerpt, so it may not cover the article in full.

### Source excerpt

Something people could ask me as they're reading this title: "Hold on a second, isn't Dagger-Android no longer in active development? Isn't it made obsolete with the introduction of Hilt?" Technically, yes. Dagger-Android is superseded by Hilt. So there is a good chance that if you are already using Hilt, then for the most common cases (injecting Activity, Fragment, ViewModel, Worker), you don't need to think about Dagger-Android whatsoever. However, as I still see @ContributesAndroidInjector popping up every now and then, I feel that it's best if I write an article on how it works, what it intended to solve, how to use it, and how NOT to use it (for better scalability). What was Dagger-Android? Dagger-Android was a way to field-inject classes (not necessarily just Android classes since Dagger 2.20+) without having to define a fun inject(target: MyConcreteClassTarget) injector method on the component -- as we don't know the class itself. When do you want to avoid creating fun inject(t: T) in a component? After all, this is what normally allows field injection to be type-safe. The answer is, when you can't. If you use a modularization pattern where :app contains the ApplicationComponent(or SingletonComponent), then while ApplicationComponent can see any Activity or Fragment within the app, the submodules don't see :app and therefore don't see ApplicationComponent. Therefore, they can't call component.inject(this)! On the other hand, if you were to define an Application.ActivityLifecycleCallbacks to do it automatically, that wouldn't work with the standard approach -- as you see only the superclass, but not the concrete class! So if one wants to use field injection with our provided restrictions, there are two options: Expose an interface from the child module that defines the injection targets, and implement that on the ApplicationComponent -- then make it possible to access it (for example, using the ApplicationContext for lookup) and cast it to the interface to be abl

## Creating a BottomNavigation Multi-Stack using child Fragments with Simple-Stack

DevFeed: [Creating a BottomNavigation Multi-Stack using child Fragments with Simple-Stack](<https://devfeed.tech/articles/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-simple-stack-25935.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-simple-stack-c73c1ca3bbd4?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-01-25T17:03:22Z

Content type: tutorial

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [bottom-navigation](<https://devfeed.tech/topics/bottom-navigation.md>), [jetpack-navigation](<https://devfeed.tech/topics/jetpack-navigation.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [bottom-navigation](<https://devfeed.tech/tags/bottom-navigation.md>), [bottomnavigationview](<https://devfeed.tech/tags/bottomnavigationview.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [history](<https://devfeed.tech/tags/history.md>), [jetpack-navigation](<https://devfeed.tech/tags/jetpack-navigation.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>)

### AI overview

For a Simple-Stack bottom navigation setup with a separate history per tab, a parent fragment hosts child fragments and keeps them alive by adding them, then detaches the hidden tabs and attaches the selected one. Simple-Stack's usual Navigator.install() provides one Activity-wide Backstack with automatic lifecycle management; separate Backstacks inside each tab require managing their lifecycle and retention across configuration changes yourself. The excerpt introduces a fragment to retain each stack and intercept back presses for the selected tab, and notes using fragment lifecycle callbacks and ScopedServices to manage nested stacks and expose stack hosts. The supplied text ends before the implementation details.

### Source excerpt

It's been a recurring question, regardless of navigation framework of choice: how is it possible to create a screen with a bottom navigation view, that would host a navigation history stack per each tab? Each framework has its own unique ways. For example, Jetpack Navigation provides NavigationExtensions as a sample, there's FragNav, but how would you do it with Simple-Stack? How bottom navigation with child fragments normally works If you intend to create a BottomNavigationView that is hosted by a Fragment (and that Fragment hosts each tab as a child fragment), there's a bit of work needed to be done. To keep the fragments alive while switching between them, they must all be added. However, to make sure that the fragments are in the correct lifecycle (stopped while not showing), it makes sense to detach them (and attach the one that is meant to be showing). https://medium.com/media/1667d9733c198c3ae611fd45504f6bd0/href This example is also available here. Please note that there is nothing specific to Simple-Stack in this snippet, this is how a fragment can manage its child fragments and keep only one of them attached, while the rest are detached. In fact, the NavigationAdvancedSample works the same way. We will use this knowledge later in the article. What Simple-Stack normally does When you use Simple-Stack, you typically install a Navigator using Navigator.install(). This allows a single global Backstack instance to be accessible through the Activity's context (and thus making it available to all views within the Activity), and provides automatic lifecycle management to ensure that navigation is handled correctly. https://medium.com/media/03bde713eca4e7ef47d7dae31f6e095d/href This is important to know, because if we want to create a Backstack for each Fragment within our BottomNavigationView, we must manage the lifecycle (and keep the Backstack instance alive across configuration changes) ourselves. Thankfully, this is actually quite simple to do! After all, frag

## Structural and navigation anti-patterns in modularized Android applications

DevFeed: [Structural and navigation anti-patterns in modularized Android applications](<https://devfeed.tech/articles/structural-and-navigation-anti-patterns-in-modularized-android-applications-25933.md>)

Original publisher: [Read original article](<https://proandroiddev.com/structural-and-navigation-anti-patterns-in-modularized-android-applications-a7d667e35cd6?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-12-25T11:38:05Z

Content type: article

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [modules](<https://devfeed.tech/topics/modules.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [Code](<https://devfeed.tech/topics/code.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [antipattern](<https://devfeed.tech/tags/antipattern.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [clean-architecture](<https://devfeed.tech/tags/clean-architecture.md>), [code](<https://devfeed.tech/tags/code.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dagger-2](<https://devfeed.tech/tags/dagger-2.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [domain-driven-design](<https://devfeed.tech/tags/domain-driven-design.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [modularization](<https://devfeed.tech/tags/modularization.md>), [modules](<https://devfeed.tech/tags/modules.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [navigation-architecture](<https://devfeed.tech/tags/navigation-architecture.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>)

### AI overview

This article examines structural and navigation anti-patterns in modularized Android applications. It traces the history of Android Clean Architecture and argues that organizing an application around top-level data, domain, and presentation modules can be problematic, particularly when the structure is adopted from educational examples rather than feature-based organization.

### Source excerpt

Structural and navigation anti-patterns in multi-module and modularized applications: The case against "Android Clean Architecture" and the "domain" moduleTop-level "domain" module is a code smell. Merry Christmas to all! The subject of this article is one that has been on my mind for a very long time. After all, "Clean Architecture" is often seen as the end goal, the hallmark of the finest of Android application code structure -- it is the best of the very best. The name itself, "Clean Architecture", signals that it's a good thing ~ after all, who wants to work with "messy" code in comparison? Of course, the title of this article shows that this isn't the conclusion we'll come to. The following tweet is closer to our final evaluation -- let us analyze why it might be accurate. Clean architecture + Android for us was like building a beautiful sailing boat in your backyard because someone on TV convinced you it's better for crossing the sea than an inflatable, while you live in the mountains and also your house is on fire. https://t.co/iGqy25wk7m The history of "Android Clean Architecture"The origins To understand "Clean Architecture" as done on Android, we must trace it back to its roots, and where/when it was made popular in the first place. As far as I'm aware, it dates back to 2014, the original proposition in "Fernando Cejas: Architecting Android... the clean way?". It was a highly influential article, as it revolutionized the structure of Android apps. Code that is actually separated across layers (back when Fragments were untrustworthy, and all code was in OS-level components), rather than just throwing everything into 2000+ line Activities? A pioneer of its time. One interesting decision however in the representative sample code was that in order to signify the strict separation of layers, these layers were each separated from one another using top-level Gradle modules, each labeled data, domain, and presentation. As we will see, this is the downfall of the sampl

## Simplified Android Development Using Simple-Stack

DevFeed: [Simplified Android Development Using Simple-Stack](<https://devfeed.tech/articles/simplified-android-development-using-simple-stack-25930.md>)

Original publisher: [Read original article](<https://medium.com/swlh/simplified-android-development-using-simple-stack-6e44ce808c35?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-11-14T03:32:51Z

Content type: article

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [parcelable](<https://devfeed.tech/topics/parcelable.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [jetpack-navigation](<https://devfeed.tech/topics/jetpack-navigation.md>)

Tags: [2015](<https://devfeed.tech/tags/2015.md>), [2016](<https://devfeed.tech/tags/2016.md>), [2017](<https://devfeed.tech/tags/2017.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [approach](<https://devfeed.tech/tags/approach.md>), [classes](<https://devfeed.tech/tags/classes.md>), [flow](<https://devfeed.tech/tags/flow.md>), [fork](<https://devfeed.tech/tags/fork.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [framework](<https://devfeed.tech/tags/framework.md>), [keys](<https://devfeed.tech/tags/keys.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [original](<https://devfeed.tech/tags/original.md>), [parcelable](<https://devfeed.tech/tags/parcelable.md>), [rewrite](<https://devfeed.tech/tags/rewrite.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>), [square](<https://devfeed.tech/tags/square.md>), [state](<https://devfeed.tech/tags/state.md>)

### AI overview

Simple-Stack tracks navigation as a back stack of immutable, Parcelable screen identifiers called keys. The article's example describes navigating by calling a method such as `backstack.goTo(new SecondScreen(detailId))`, with the framework abstracting fragment transactions and argument Bundles. Its author says the library grew from experience with Flow and Mortar: maintaining a fork and encountering limitations motivated a rewrite intended to be reliable, versioned, and improved. The excerpt introduces type-safe Fragment navigation but cuts off before showing setup steps.

### Source excerpt

It's been a long time since I've wanted to write this article. Time to go at it, shall we? :) People always seem to be surprised and say, "wait, you DON'T use Jetpack ViewModel, Jetpack Navigation, and Dagger-Hilt? Then what DO you use?" This article intends to answer that. We use Simple-Stack. (If you prefer watching talks, then a talk on the same subject is available at https://www.youtube.com/watch?v=5ACcin1Z2HQ) What is Simple-Stack? Simple-Stack is a navigation framework that I've been working on since the beginning of 2017, although its roots go back to 2015 -- when we were still experimenting with multiple versions of Mortar & Flow. (The 90s kids might still remember). Following up on the original proposition by Square, "Advocating Against Android Fragments" and "Simpler Android Apps with Flow and Mortar", we've been using Single-Activity approach in our apps since 2015. Now, the history of Flow and Mortar isn't all roses. I've heard people say "we tried it and it didn't work for us". I can attest to that: we had to manage our own fork, but even with that, we hit some of its limitations over time. We needed something reliable and versioned, so we rewrote Flow's original behavior, and intended to improve upon its limitations. This rewrite is what resulted in the creation of Simple-Stack. Why Simple-Stack? Simple-Stack is based on the idea that you intend to track your navigation state as a list of immutable and Parcelable classes -- screen identifiers (which the library calls "keys"). As long as the underlying navigation implementation allows for "navigation from any state to any state", it is possible to wrap that implementation using Simple-Stack. For example, something I hear often is that "navigation with Fragments is hard". I always point out that in our code, it's been like this since 2016: backstack.goTo(new SecondScreen(detailId)); // java No explicit fragment transaction, no Bundle, no newInstance(), just calling a method. How is this possible? Isn't Fr

## Building Reactive UIs with LiveData and SavedStateHandle (or equivalent approaches)

DevFeed: [Building Reactive UIs with LiveData and SavedStateHandle (or equivalent approaches)](<https://devfeed.tech/articles/building-reactive-uis-with-livedata-and-savedstatehandle-or-equivalent-approaches-25928.md>)

Original publisher: [Read original article](<https://itnext.io/building-reactive-uis-with-livedata-and-savedstatehandle-or-equivalent-approaches-4e934487035f?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-10-04T19:53:05Z

Content type: article

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [reactive](<https://devfeed.tech/topics/reactive.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>)

Tags: [activation](<https://devfeed.tech/tags/activation.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-open-source-project](<https://devfeed.tech/tags/android-open-source-project.md>), [apache](<https://devfeed.tech/tags/apache.md>), [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [background](<https://devfeed.tech/tags/background.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [observable](<https://devfeed.tech/tags/observable.md>), [observer](<https://devfeed.tech/tags/observer.md>), [query](<https://devfeed.tech/tags/query.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>), [repositories](<https://devfeed.tech/tags/repositories.md>), [room](<https://devfeed.tech/tags/room.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [savedstatehandle](<https://devfeed.tech/tags/savedstatehandle.md>), [state](<https://devfeed.tech/tags/state.md>)

### AI overview

LiveData's lifecycle callbacks let it act as a reactive data source: it can start observing when active and stop when inactive. The excerpt shows Room refreshing invalidated queries and a Firebase listener being attached and removed through those callbacks. For UI state, it combines SavedStateHandle-backed values into derived values and validation results; it also warns that getLiveData(key, initialValue) may not persist the initial value to the Bundle and gives a workaround. For asynchronous loading, switchMap can select data by changing state, while the liveData coroutine builder can emit results or connect to another LiveData source, with cancellation after inactivity subject to a default five-second timeout. The article presents RxJava and Flow as viable alternatives or interop options, including Flow.asLiveData(), while emphasizing SavedStateHandle for process restoration.

### Source excerpt

Building Reactive UIs with LiveData and SavedStateHandle (or equivalent approaches like Rx) You can also follow the related discussion thread on /r/android_devs. LiveData is a misunderstood beast. Every so often, you see comments like "LiveData does not belong in Repositories", or that with the existence of RxJava, Coroutine Channels, or Coroutine Flows -- there's "no reason to use LiveData at all". While there are components in these libraries that have overlapping responsibilities (BehaviorRelay, ConflatedBroadcastChannel, MutableStateFlow), that doesn't mean LiveData is useless. With the relatively new additions to Jetpack, such as the liveData { coroutine builder, LiveData is actually quite interesting. What is LiveData? If you try to find a definition for LiveData, you'll find that it's a "reactive, observable, lifecycle-aware data holder". We know it can be observed, and we know it holds 1 data value that is re-emitted for any new observer (and any changes made to it are also emitted), just like any BehaviorRelay. But what makes it special? Due to LiveData's lifecycle-awareness, it comes with its own "activation state" ( onActive and onInactive). It lets you know when there is an active observer, and when there are no longer any active observers. The trick is that this makes it far more than "just an every-day data holder". This allows LiveData to represent reactive datasources. I'd even wager that this is the original purpose for which LiveData was created, if Room's ComputableLiveData is any indication (as that also relies on onActive to trigger the refresh of the query results, if the table had been invalidated by a write to it). Why do I want reactive datasources? If you have data or state that can change over time, it's significantly easier to be notified of changes, than it is to poll for possible changes (and potentially miss out on changes if we tried to fetch data at the wrong time). This means that by using an "observer" (or change listener), we can r