4 ms·
User input validation benefits from using notifications, internal logic checks (input coming from another part of the code) should raise exceptions. Expected b
by pierotofy 12y ago
User input validation benefits from using notifications, internal logic checks (input coming from another part of the code) should raise exceptions.
Expected behavior --> notifications. Unexpected behavior --> exceptions. Simple.
- mwhite 12y agoExactly. This article doesn't address the fact that for most programs you ideally want to have a separate UI validation where you're dynamically validating the user input before it gets submitted, and an internal validation where you validate the data before it gets saved, but also possibly even after it gets saved, relative to pre-existing data (where you could throw an exception and abort the transaction if it didn't validate). If you want to use some of the same validation code for user input validation and internal validation, I suppose you could modify the notation pattern to conditionally throw an exception when adding a new error depending on whether it's on the client or the server.
- dragonwriter 12y ago> If you want to use some of the same validation code for user input validation and internal validation, I suppose you could modify the notation pattern to conditionally throw an exception when adding a new error depending on whether it's on the client or the server. Or you reuse the validation code itself, but called from a wrapper that turns notifications into exceptions, rather than adding branches.