Stop Using Exceptions for Validation: Use the Notification Pattern instead
When you use exceptions during validation for example you trigger a "fail-fast" response. The program stops at the first error it finds and throws the exception.
If a user submits a form with let's say 5 errors, the fail-fast approach results in frustrating experience:
The user fixes one error… submits again… gets another error… repeats 5 times.
Solution? Use the Notification Pattern (popularized by Martin Fowler).
The benefit of introducing such a class is that you can now declare a validator that is able to collect multiple errors in one pass. Instead of throwing exceptions, you can now simply add messages into the Notification object.
This approach leads to better user experience and a cleaner easier to maintain flow.
Do you prefer fail-fast or collecting all errors?