|
|
|
|
|
by pansa2
1820 days ago
|
|
“Parse, don’t [just] validate”. Say I have a string that’s supposed to represent an integer. To me, “Validate” means using a regex to ensure it contains only digits (raising an error if it doesn’t) but then continuing to work with it as a string. “Parse” means using “atoi” to obtain an integer value (but what if the string’s malformed?) and then working with that. I first thought this article was recommending doing the latter instead of the former, but the actual recommendation (and I believe best practice) is to do both. |
|