Skip to content

refactor(tutorials): decouple Places API models from UI with PlaceItemUiModel and mapper - #2457

Draft
dkhawk wants to merge 1 commit into
mainfrom
refactor/current-place-ui-model
Draft

dkhawk wants to merge 1 commit into
mainfrom
refactor/current-place-ui-model

Conversation

@dkhawk

@dkhawk dkhawk commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors the CurrentPlaceDetailsOnMap tutorials (both Java and Kotlin) to decouple the external Places API data model from the UI layer:

  • Eliminates Parallel Arrays: Removed likelyPlaceNames, likelyPlaceAddresses, likelyPlaceAttributions, and likelyPlaceLatLngs along with their mutable Activity instance fields.
  • Introduces PlaceItemUiModel: Simple presentation model holding pre-formatted, display-ready strings and coordinates (title, snippet, position).
  • Introduces toUiModel() Mapper: Encapsulates data normalization, fallback defaults (such as fallback titles), and string formatting (including third-party attributions) in a dedicated mapper, preventing business and formatting logic from leaking into UI components.
  • Dumb UI: The selection dialog and marker creation logic now directly bind PlaceItemUiModel without thread-side concatenation, raw types, or null checks.
  • Literate Programming: Added explanatory docstrings to clarify the architectural rationale behind decoupling and mapper design.
  • New Region Tag: Wrapped the UI model and mapper in maps_current_place_ui_model to allow seamless integration into the developer tutorial documentation.

Testing

  • :tutorials:java:CurrentPlaceDetailsOnMap:assembleDebug passed
  • :tutorials:kotlin:CurrentPlaceDetailsOnMap:assembleDebug passed
  • spotlessCheck passed

…emUiModel and mapper

Introduce PlaceItemUiModel and a dedicated mapper (toUiModel) in both Java and Kotlin CurrentPlaceDetailsOnMap tutorials.

- Remove the legacy four parallel arrays (likelyPlaceNames, likelyPlaceAddresses, likelyPlaceAttributions, likelyPlaceLatLngs) and their Activity instance fields.
- Decouple the Places API data model from the UI layer: the selection dialog and map markers now consume a dumb, display-ready PlaceItemUiModel.
- Centralize default value fallbacks, null-coalescing, and string formatting (including third-party attributions) in the mapper.
- Add literate programming commentary explaining the architectural decoupling and mapper design.
- Wrap UI model and mapper in a new region tag: maps_current_place_ui_model.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant