Different Output Models for Different Use Cases
Learn about different output models for different use cases and how they can help in writing maintainable code.
We'll cover the following
Returning data
Once the use case has done its work, what should it return to the caller?
Similar to the input, it has benefits if the output is as specific to the use case as possible. The output should only include the data that is really needed for the caller to work.
In the code example of the “Send Money” use case above, we return a boolean
. This is the minimal and most specific value we could possibly return in this context.
Returning entire object
We might be tempted to return a complete Account
with the updated entity to the caller. Perhaps the caller is interested in the new balance of the account?
Get hands-on with 1400+ tech skills courses.