Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

UseCase problem?

Open xudshen opened this issue 11 years ago • 1 comments

Hi, I'm recently working on my android project code refactoring and I find your project.

I'm confused about using UseCase class which will be @Inject in Presentation Layer to get the data in Data Layer. Will this be more convenient if we just @Inject the UserRepository in Presentation Layer directly, since UseCase(GetUserDetails) is just some kind of wrapping of UserRepository from my point of view.

Like this:

class UserDetailsPresenter{
    private UserRepository userRepository;
    ...
    @Inject
    public UserDetailsPresenter(UserRepository userRepository){
        ...
    }    
    ...
    //get the user detail
    userRepository.user(this.userId).subscribeOn(...).observeOn(...).subscribe((data)->{});
    ....
}

xudshen avatar Oct 25 '15 14:10 xudshen

For something that simple, yes it does appear to work. However as your data sets get more complicated, a UseCase can encompass combining multiple elements from the repository, and explicitly having this layer define what repository elements create a UseCase is supposed to help it scale as necessary.

caseykulm avatar Oct 26 '15 15:10 caseykulm