Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetSearchContentsCountUseCase should not exist #1283

Closed
dturner opened this issue Mar 14, 2024 · 2 comments · Fixed by #1284
Closed

GetSearchContentsCountUseCase should not exist #1283

dturner opened this issue Mar 14, 2024 · 2 comments · Fixed by #1284

Comments

@dturner
Copy link
Collaborator

dturner commented Mar 14, 2024

Callers should call the repository interface directly.

https://github.com/android/nowinandroid/blob/main/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsCountUseCase.kt

sanao1006 added a commit to sanao1006/nowinandroid that referenced this issue Mar 15, 2024
…hViewModel

- Remove GetSearchContentsCountUseCase.
- Remove GetSearchContentsCountUseCase from SearchViewModel.
- Remove GetSearchContentsCountUseCase from SearchViewModelTest.

Fixes android#1283
@Jaehwa-Noh
Copy link
Contributor

Jaehwa-Noh commented Mar 15, 2024

I wonder why we should remove that use case rather than migrate the business logic from repository?

When we decide to use optional domain layer, move the repository's business logic to domain layer. It makes sense to me.

I read this documentation.

Threading



The reason of deleting use case is that so complicated to apply domain?

Typically, complex computations happen in the data layer to encourage reusability or caching. For example, a resource-intensive operation on a big list is better placed in the data layer than in the domain layer if the result needs to be cached to reuse it on multiple screens of the app.

And complex computations is so abstract word to me, then I am hard to decide and determine the baseline when I choose whether use domain layer or not.

In this 'Now in Android', is this GetSearchContentsCountUseCase, and getSearchContentsCount in DefaultSearchContentRepository business logic complex to use in domain?

@yongsuk44
Copy link
Contributor

Following the same reasoning, what do you think about eliminating GetRecentSearchQueriesUseCase and instead allowing SearchViewModel to directly interact with the repository interface? This could simplify the architecture.

@dturner

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 a pull request may close this issue.

4 participants
@dturner @yongsuk44 @Jaehwa-Noh and others