Reader small image

You're reading from  Get Your Hands Dirty on Clean Architecture - Second Edition

Product typeBook
Published inJul 2023
PublisherPackt
ISBN-139781805128373
Edition2nd Edition
Right arrow
Author (1)
Tom Hombergs
Tom Hombergs
author image
Tom Hombergs

Tom Hombergs is a software engineer by profession and by passion with more than a decade of experience working on many different software projects for many different clients across various industries. In software projects, he takes on the roles of software developer, architect, and coach, with a focus on the Java ecosystem. He has found that writing is the best way to learn, so he likes to dive deep into topics he encounters in his software projects to create texts that give structure to the chaotic world of software development. He regularly writes about software development on his blog and is an occasional speaker at conferences.
Read more about Tom Hombergs

Right arrow

Different input models for different use cases

We might be tempted to use the same input model for different use cases. Let’s consider the Register account and Update account details use cases. Both will initially need almost the same input, namely some account details, such as a username and email address.

The Update use case will need the ID of the account that needs to be updated, however, while the Register use case does not. If both use cases use the same input model, we will always have to pass a null account ID into the Register use case. This is annoying at best, and detrimental at worst, because both use cases are coupled to evolve together now.

Allowing null as a valid state of a field in our immutable command object is a code smell by itself. But more importantly, how are we handling input validation now? Validation has to be different for the Register and Update use cases since one needs an ID and the other doesn’t. We’d have to build custom validation...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Get Your Hands Dirty on Clean Architecture - Second Edition
Published in: Jul 2023Publisher: PacktISBN-13: 9781805128373

Author (1)

author image
Tom Hombergs

Tom Hombergs is a software engineer by profession and by passion with more than a decade of experience working on many different software projects for many different clients across various industries. In software projects, he takes on the roles of software developer, architect, and coach, with a focus on the Java ecosystem. He has found that writing is the best way to learn, so he likes to dive deep into topics he encounters in his software projects to create texts that give structure to the chaotic world of software development. He regularly writes about software development on his blog and is an occasional speaker at conferences.
Read more about Tom Hombergs