android / android/architecture-samples
[todo-mvp] Add TasksCacheDataSource
- Dominant language
- Kotlin
- Stars
- 45.8k
- Forks
- 11.9k
- PR merge metrics
- No merged PRs in 30d
Description
I've noticed that the cache and the caching logic is in the TasksRepository class which, I believe, violates the single responsibility principle. Would it be worth it to create an abstraction for the cache by adding another class? It wouldn't follow the TasksDataSource interface as its functionality is a little different but it would remove a responsibility from TasksRepository and get rid of a lot of if statements that are used for null checks.
I'm going to implement a version of this and see if it works.
Contributor guide
Research direction
Start by reading TasksRepository and the TasksDataSource interface to understand the current cache ownership and how their responsibilities differ. The change is complete when cache handling is separated into a TasksCacheDataSource and TasksRepository no longer contains the cache-related null checks, with the existing task behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100