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 best to break up large use cases? #77

Open
ydennisy opened this issue Jan 24, 2022 · 1 comment
Open

[Question] How best to break up large use cases? #77

ydennisy opened this issue Jan 24, 2022 · 1 comment

Comments

@ydennisy
Copy link

ydennisy commented Jan 24, 2022

Hi @stemmlerjs !

I was wondering if you have any insight into how best to break up large use-cases?

I have some constructors which now look like the following:

  private usersRepo: UsersRepo;
  private dealsRepo: DealsRepo;
  private brandsRepo: BrandsRepo;
  private audiencesRepo: AudiencesRepo;
  private googleService: GoogleService;
  private brandService: BrandService;

Is this where the concept of a service would come in and we would have a relationship such as controller -> use-case -> services[brand, user, ...]

Thanks in advance!

@gbrennon
Copy link

gbrennon commented Apr 8, 2023

Hey buddy! How are u doing?

One thing that can guide u is reason about the "NAME" of that UseCase! This is a good reference to reason about that abstraction purpose.

What u can do to solve this:

  • remember: an application service should ORCHESTRATE lower-level operations
  • distribute the business logic between domain services, entities and value objects
  • think about why u are bearing those dependencies

i would suggest u applying domain events to decouple computations! imagine that we define some usecase named AcceptUserDeal. This usecase would be responsible for persisting user and deal modifications in the database and AT THE END OF THE TRANSACTION u could be publishing a UserDealAccepted domain event!

this domain event would be handled by other usecase, for example, PublishDealDetails and then this one would relate to creating a google+ post or whatever u want to do.

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