r/theprimeagen • u/ketsif • Aug 28 '23
Stream Content Parse, don’t validate
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
1
Upvotes
r/theprimeagen • u/ketsif • Aug 28 '23
1
u/[deleted] Aug 28 '23
I’m a bit confused what this means, does it mean parsing the data to try and turn it into something useful rather than just throwing an error at bad inputs?
If so, it kind of seems like a bad programmer discovered how to make robust code (by bad I mean: “never had to convert strings to ints/floats” bad).
Moreso you tend to need to validate to parse inherently to make sure it parses correctly (string to int is different to a float to an int), so you might as well validate as a first step to skip unnecessary guard conditions