3 ms·
Your response isn't clear. >that component really shouldn’t be validating the structure of email addresses That's right, as the article says you no longer val
by Kranar 5y ago
Your response isn't clear.
>that component really shouldn’t be validating the structure of email addresses
That's right, as the article says you no longer validate data, instead you parse data. Components don't take strings and validate them, they take an EMail address.
>If you need to refine the parsing logic now you’ve got to do coordinated deployments
If you need to refine the parsing logic, you modify the constructor of the EMail class to do whatever refinements you need.
I have no doubt you may have seen codebases that did something wrong, and that wrong thing may have been related to parsing or validation, but nothing you've said indicates that there is something wrong with replacing validation with parsing, so that code always operates on semantically meaningful data types that are valid by construction, instead of opaque binary blobs that need to constantly be properly interpreted in ad-hoc ways.
- cle 5y agoI guess what I'm saying is to be judicious about what invariants a particular piece of code should care about, within the context of the larger system. > That's right, as the article says you no longer validate data, instead you parse data. Components don't take strings and validate them, they take an EMail address. That doesn't solve the problem, by parsing it my code is caring about its syntax and structure, even if my use case doesn't require that. That creates coupling, and in a distributed system that kind of unnecessary coupling can create major headaches when trying to change things. An even simpler example that many people can empathize with is using strict, closed enums in a distributed system (very easy to do with e.g. Java). Safely adding a new enum value is basically impossible at that point, until you make them "open" enums that can safely parse unknown values. Again I am not disagreeing in principle, I am only saying that this has ergonomic problems in practice and is easy to misuse.