Skip to content

Borrow Dish base-class discipline for Android — ADR before Kotlin work starts #32

Description

@stanvx

Parent

Architecture review (2026-06-21). Slice 6 of 6 from the deepening series. Speculative — the Android Kotlin work has not yet started, so this is preventive architecture. Documented at android/rust/usbip-android/src/lib.rs:26.

What to build

Before any Kotlin UI/state code is written, copy the base-class discipline from Dish-Android wholesale:

  • AbstractStateSource<S> — single owner of a StateFlow<S>, with val state: StateFlow<S> and an abstract protected fun compute(): S
  • AbstractComposer<S, A> — translates a state into a Composable function; no business logic
  • AbstractController<S, A> — accepts user actions, mutates the StateSource, never directly mutates state

Write an ADR (docs/adr/0007-android-base-classes.md) capturing the decision with a code skeleton inline. The base classes themselves live in android/core/src/main/java/com/anyplug/base/ and ship as a real, instantiable package even before the first concrete subclass lands.

This is cheap now (3 small files) and expensive to add later (every existing state-source would need to be retrofitted).

Acceptance criteria

  • android/core/src/main/java/com/anyplug/base/AbstractStateSource.kt exists with KDoc explaining the discipline and a single abstract method
  • android/core/src/main/java/com/anyplug/base/AbstractComposer.kt exists
  • android/core/src/main/java/com/anyplug/base/AbstractController.kt exists
  • ADR 0007 (docs/adr/0007-android-base-classes.md) explains the decision, references the Dish-Android original, and shows a code skeleton
  • CONTEXT.md "module ownership" section has AndroidStateOwner, AndroidComposerOwner, AndroidControllerOwner entries pointing at these classes
  • A unit test in android/core/src/test/java/com/anyplug/base/ proves the StateFlow round-trips a compute() result correctly
  • No existing Kotlin file (MainActivity, ServerDiscovery, etc.) is refactored to use the new base classes — that's follow-up work, gated on this ADR

Blocked by

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentTriage complete; ready for an agent to implement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions