docs: add architecture guidelines and programming standards - #62
Conversation
dkhawk
left a comment
There was a problem hiding this comment.
Overall this is a fantastic addition! Formalizing Clean Architecture, 3-way parity, the 4-tier testing strategy, and AI pair-programming hygiene is a huge win for maintaining consistency across android-maps3d-samples. The inclusion of the pragmatic, non-blocking incremental adoption rules in GEMINI.md is especially valuable.
Here is some constructive feedback and suggestions for polish:
-
Clarify
StateFlowvsLiveDataand theasLiveData()approach:- Generally speaking, we should keep
StateFlowas the standard for Kotlin and Jetpack Compose implementations, and reserveLiveDatafor Java implementations. Pure Kotlin/Compose modules should rely solely onStateFlow. - The
asLiveData()approach is primarily relevant for hybrid solutions (like the sharedcommonmodule inMaps3DSamples/ApiDemos) where a single ViewModel powers Kotlin, Compose, and Java views. - For those hybrid ViewModels, using
val liveData: LiveData<T> = _uiState.asLiveData()(as currently done inPathFollowingViewModelandAdvancedCameraAnimationViewModel) is much cleaner than manually managing a dual-state_liveData+updateStatefunction with atry/catchblock falling back topostValue(). It automatically handles coroutine thread-dispatching and eliminates redundant mutable backing properties.
- Generally speaking, we should keep
-
Soft Line Count Guideline for Views (<250 lines):
- In
ARCHITECTURE.mdSection 2.A, view layers are noted with a<200 linestarget, whereas Sections 1, 2.B, 3, 7, andGEMINI.mdcite< 250 lines. - While arbitrary hard line limits can be overly rigid, setting a consistent "soft" target of ~250 lines across all sections is a good guideline to keep view layers thin and focused while maintaining consistency throughout the documentation.
- In
-
Markdown / LaTeX Arrow Formatting in
ARCHITECTURE.md:- In Section 3 (Layer 4), the UDF flow uses LaTeX math syntax
$\rightarrow$:
Views emit user intents $\rightarrow$ ViewModel processes via Repository/Controller $\rightarrow$ Emits immutable State $\rightarrow$ Views render. - Replacing
$\rightarrow$with standard Unicode arrows (→or->) will ensure clean rendering in all markdown viewers, IDE previews, and mobile GitHub views without relying on KaTeX math rendering.
- In Section 3 (Layer 4), the UDF flow uses LaTeX math syntax
-
Region Tag Guidance for
snippets/inGEMINI.md:- Under Section 4 ("Code Generation Hygiene & Linter Standards"), consider adding a note reminding contributors and AI tools to preserve and utilize region tags (
// [START ...]...// [END ...]) when working insnippets/. This ensures snippet boundaries remain discoverable and compatible with the repository's automated catalog scripts and documentation extractors.
- Under Section 4 ("Code Generation Hygiene & Linter Standards"), consider adding a note reminding contributors and AI tools to preserve and utilize region tags (
|
What if we use an agent neutral markdown file, like AGENTS.md? I assume not everybody will use Gemini. |
| │ ├── kotlin-app/ | ||
| │ │ └── src/main/java/com/example/maps3dkotlin/<feature>/ | ||
| │ │ └── <Feature>Activity.kt # Layer 5: Thin View (~250 lines soft guideline) collecting StateFlow | ||
| │ └── java-app/ |
There was a problem hiding this comment.
What if we align the tree branches for java-app/? It's drawn with └── as the last child of ApiDemos/, but the two lines beneath it still carry the │ │ continuation prefix, which leaves a stray vertical line hanging under a closed branch. Dropping the second pipe would keep the diagram consistent:
│ └── java-app/
│ └── src/main/java/com/example/maps3djava/<feature>/
│ └── <Feature>Activity.java
Purely cosmetic, but since this blueprint is the visual anchor of the doc, it's worth the tidy-up.
Good point! I kept it as GEMINI.md because the current implementation and guidelines are strictly tailored to Gemini. I figured it's best to be explicit about what is currently supported. If we expand to other agents later on, we can definitely migrate to an AGENTS.md approach. Let me know if that makes sense! |
I think we should go for the standardization rule, there are not that many differences today between agents, and there will be less differences in the future. This is already a field prone to standardization. |
…gn tree diagram branches under java-app
That makes total sense, @kikoso! You're completely right that standardizing on |
|
🎉 This PR is included in version 1.12.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Establishes comprehensive Clean Architecture guidelines and programming standards for
android-maps3d-samples:ARCHITECTURE.md:
Maps3DSamples) and standalone showcase modules (PlacesUIKit3D).AltitudeMode, consumable camera animation commands, and lifecycle forwarding).collectAsStateWithLifecycle()standards.AGENTS.md: