Refactor: moved business logic to Use Cases and added unit test suite - #1080
Merged
Conversation
Owner
|
@gietabhi10 Indeed, this was needed. The ViewModel was growing :P Also, did you follow CONTRIBUTING.md? I don't see any attribution Also, be sure that the app still behaves the same Thanks! I'll wait for the feedback |
Author
|
@PranshulGG Thanks for the feedback! I've updated the PR to address your points:
Ready for a final review! 🌦️ |
PranshulGG
approved these changes
Aug 25, 2026
Owner
|
@gietabhi10 Can you rebase and fix up the conflicts? |
# Conflicts: # app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/WeatherViewModel.kt
…ts, and refine threading
…ding, and add cancellation tests
Author
|
@PranshulGG Thanks for the review! I've updated the PR with the following:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🏗️ Architectural Refactor
Issue: [Feature Request] Refactor Business Logic to Use Cases and Setup Testing Suite
Problem Statement: The WeatherViewModel has grown to over 450 lines, taking on too many responsibilities including coordinate reconciliation, parallel data fetching orchestration, and layout management. This high coupling makes it difficult to unit test business logic without mocking the entire UI state. Furthermore, layout management logic is currently duplicated between WeatherViewModel and DailyScreenViewModel, making the codebase harder to maintain. There is also no established infrastructure for modern unit testing (MockK, Coroutine testing).
Proposed Solution:
Alternatives Considered:
Keeping logic in Repositories: Rejected because complex orchestration (like coordinate updates combined with weather fetching) belongs in a Use Case to keep repositories focused on data mapping.
Hilt-only testing: Rejected in favor of pure unit tests for the domain layer for faster execution.
Acknowledgements:
[x] I have searched the existing issues.
[x] I understand that submitting a request does not guarantee it will be implemented.
[x] I have provided all necessary information.