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

[QUESTION] How to avoid duplicate interactor #4

Closed
hukacode opened this issue Jan 26, 2018 · 4 comments
Closed

[QUESTION] How to avoid duplicate interactor #4

hukacode opened this issue Jan 26, 2018 · 4 comments

Comments

@hukacode
Copy link

Hello,

What if I create a new use case, like getSomething, and use the same DoesExchangeExist class.
Should I use this class or create new class for new use case?
Thanks in advance!

Best regards,
Huka

@mattia-battiston
Copy link
Owner

Hi Hung

The easiest thing you can do is extract the DoesPostEsisted class to a common package and reuse it from both use cases. I don't see anything wrong with it, as it sounds like it's part of your business logic.

I hope this answer your questions
Cheers

@hukacode
Copy link
Author

hukacode commented Jan 26, 2018

Hi @mattia-battiston

Thank you so much for your comment.
Do you mean I should create another common use case and use it in other use cases?

Example:

  • Put common interactor in common package:
    com.example.core.usecase.common.DoesPostEsisted.java

  • Used in:
    com.example.core.usecase.getcapacity.GetCapacityForExchangeUseCase.java

  • And
    com.example.core.usecase.getSomething.GetSomethingForSomethingUseCase.java

Edit:
I think it should be called Boundaries, not Interactors, is it right?

Thanks,
Hung.

@mattia-battiston
Copy link
Owner

yes, that's what I mean. There's nothing wrong in extracting duplicate code, as long as you still respected the fact that in core we only want business logic.

Not sure what you mean by boundaries vs interactors though?

Mattia

@hukacode
Copy link
Author

I'm confusing, Boundaries are interface, Interactors are Usecases.
Maybe DoesPostEsisted.java is Boundary and used in others Usecases.
I will search Google for more details.

Thank you for supporting, I really appreciate it.

Have a good day!
Hung

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

No branches or pull requests

2 participants