A Use Case in a Nutshell
Explore how to implement a use case by handling inputs, validating business rules, manipulating model state, and interacting with adapters. Understand the separation of input validation from business logic and how to isolate use cases in service classes for cleaner architecture.
We'll cover the following...
We'll cover the following...
First, let’s discuss what a use case actually does. Usually, it follows these steps:
- Take input.
- Validate business rules.
- Manipulate model state.
- Return output.
A use case takes input from an incoming adapter. You might wonder why this step was not called “Validate input”. The answer is that use case code should care about the domain logic, and we shouldn’t pollute it ...