Your Assumptions Are Wrong
Find the English version below
Hi ,
Deine E-Mail-Validierung ist falsch (wahrscheinlich). Und deine Modellierung, dass jeder Mensch einen Vor- und einen Nachnamen hat, ist ebenfalls falsch.
Als ich in den vergangenen Tagen meine Bookmarks auf der Suche nach einem Artikel zu Project Management in BigTech durchforstet habe, bin ich auf einen alten Artikel von 2010 gestolpert: Falsehoods Programmers Believe About Names.
Ein exzellentes Essay!
Unsere Annahmen sind falsch
Vielleicht hast du schon erlebt, dass nicht jeder Mensch genau einen Vor- und Nachnamen hat. Und vielleicht hattest du schon einen Supportfall, dass sich Namen ändern. Es soll ja Menschen geben, die heiraten 😉
Aber es gibt noch viel außergewöhnlichere Eigenschaften von Namen. Es gibt Namen mit Zahlen. Manche werden in CAPSLOCK geschrieben. Ein Name wird erst Jahre nach der Geburt zugewiesen. Manche Namen sind auch Schimpfwörter.
Ich könnte die Liste von Patrick McKenzie jetzt wiederholen, aber schau doch mal in sein Essay.
Für uns als Entwickler muss aber hängenbleiben: Jegliche Annahme, die wir an Namen stellen, ist falsch. Du solltest beispielsweise folgendes nicht machen:
- Eine Vor- und Nachnamenspalte haben
- Die Zeichenlänge von Namen limitieren
- Das Zeichenset limitieren
- Einen Unique Constraint setzen
- Oder irgendeine Form der Validierung auf den Namen anwenden
Deine E-Mail-Validierung ist auch falsch
Hast du schon mal in die Adressspezifikation von RFC 5322 geschaut?
Das hier sind alles korrekte E-Mail-Adressen:
long.email-address-with-hyphens@and.subdomains.example.com
name/surname@example.com
admin@example
example@s.example
" "@example.org
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
_test@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]
(Auf Wikipedia findest du noch mehr Beispiele)
Ich bin mir ziemlich sicher, dass deine Implementierung nicht alle Beispiele unterstützt.
Der einzig korrekte Weg, eine E-Mail-Adresse zu validieren, ist eine Aktivierungsmail zu schicken.
Wir meinen es gut - aber es ist die Mühe nicht wert
Was müssen wir daraus mitnehmen?
Viele unserer Annahmen sind gut gemeint - aber falsch. Sei dir dessen bewusst. Und berücksichtige das im nächsten Grooming, wenn es wieder darum geht, ein Formular mit Vor- und Nachnamen anzulegen.
Rule the Backend,
~ Marcus
Hi ,
Your email validation is probably incorrect. And your model that every person has a first and last name is also incorrect.
While I was rummaging through my bookmarks in the past few days looking for an article on Project Management in BigTech, I stumbled upon an old article from 2010: Falsehoods Programmers Believe About Names.
An excellent essay!
Our Assumptions are Wrong
Perhaps you've already experienced that not every person has exactly one first and last name. And maybe you've had a support case where names change. After all, there are people who get married 😉
But there are even more extraordinary characteristics of names. There are names with numbers. Some are written in CAPSLOCK. A name is assigned years after birth. Some names are also swear words.
I could repeat Patrick McKenzie's list now, but check out his essay.
For us as developers, however, the takeaway should be: Any assumption we make about names is wrong. For example, you should not do the following:
- Have a first and last name column
- Limit the character length of names
- Limit the character set
- Set a unique constraint
- Or apply any form of validation to the name
Your Email Validation is Also Wrong
Have you ever looked into the address specification of RFC 5322?
These are all correct email addresses:
long.email-address-with-hyphens@and.subdomains.example.com
name/surname@example.com
admin@example
example@s.example
" "@example.org
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
_test@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]
(You can find more examples on Wikipedia)
I'm pretty sure your implementation does not support all these examples.
The only correct way to validate an email address is to send an activation email.
We Mean Well - But It's Not Worth the Effort
What do we need to take away from this?
Many of our assumptions are well-intentioned - but wrong. Be aware of this. And consider it in the next grooming session when it comes to setting up a form with first and last names.
Rule the Backend,
~ Marcus