
Ask HN: What is the best way to verify forms - __manuels__
To be honest, I hate GUI programming. You always have to verify the data a user enters and convert this data into your data structures.
You could do it the easy way and just make the GUI elements reflect the schema of your data structure, but often this approach is not very user-friendly.<p>E.g. it&#x27;s easier for the user to enter a list of IP addresses separated by commas, but your data structure holds an array of IP addresses. If the user enters invalid data, this must be shown in the GUI as an error.<p>And anytime the user modifies something, the data structures have to be modified (or not, depending on whether you decide to save automatically or have a &#x27;save&#x27; button) and certain parts of your GUI have to be updated, too.<p>Usually when I start writing something like this, it becomes incredibly complex code.<p>What is the best <i>concept</i> to handle serialize and de-serialize user input in a GUI?
Any good videos of talks about this?<p>I am not looking for a specific library in JS, C++ or what ever, but rather for a concept&#x2F;programming pattern&#x2F;whatever to deal with this situation.
======
sethammons
You develop a feel for it. I'm not sure if there is a silver bullet to this.
Specific examples and cases are easier to give answers to. Your list of IP
addresses is a solid one. You might think a comma separated list is easiest
(and maybe it is), but you could likely have a single input field and a "\+
add another IP" link that dynamically adds a new IP input field.

You either make it more structured and need less validations and transforms or
you make it more free form and need more validations and transforms. And it
depends on the case. In the end, you probably want to construct some JSON that
maps to part or all of your data structure. Depending on how important it is
to get the data "right," you can also prompt the user with a "does this look
right?" confirmation. Also, don't forget all the "falsehoods programmers
believe about" articles.

