Pick the fix
A ViewModel calls Retrofit, maps JSON, caches in a HashMap and formats prices. What's the best first refactor?
Hint 1 of 1
Which parts are about where data comes from?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Move fetching, mapping and caching into a repository; keep formatting for the UI
Correct. The data layer owns sources and caching; the ViewModel just exposes UI state.
Why not the others?
- B Move everything into a single use case. That just moves the god class.
- C Make the ViewModel a singleton. Lifetime isn't the problem; responsibilities are.
- D Split the ViewModel into four ViewModels. The screen still mixes data and UI concerns.