3 ms·
If you're processing an HTML form then 'name' could be the form name attribute, the input element name attribute, the person's name, the person's username, the
by onion2k 10y ago
If you're processing an HTML form then 'name' could be the form name attribute, the input element name attribute, the person's name, the person's username, the person's identifier within the application or database, and so on. Try reading some badly written PHP form handling code where the logic and the HTML are in the same script and you see this precise problem.
- M2Ys4U 10y agoSurname is only seven letters and it doesn't suffer those problems
- zeta0134 10y agoIt suffers a different problem though: Name implies your given name, possibly including your family name. Surname is much more specific (family name only) and thus not suitable in any case where that's not what you meant. This is not an easy problem to solve. For every "easy" example of a good name, one readily encounters an easy counterexample that renders the name ambiguous or unfit for a particular purpose. Names must necessarily include context to be meaningful. If "name" is an unambiguous identifier in your scope and it's obvious what it does, great! Don't fix what isn't broken. But when you catch ambiguity or uncertainty, revisit the code, so future developers have an easier time understanding what you meant.
- TeMPOraL 10y ago> It suffers a different problem though: Name implies your given name, possibly including your family name. Surname is much more specific (family name only) and thus not suitable in any case where that's not what you meant. And this digs out a tangential problem - that often, "name" is as specific as you can get (or at least as specific as you should get) - http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-b....
- barrkel 10y agoThis is definitely a problem when you mix different semantic concerns in one level of code. Doctor, it hurts when ...