编程与软件工程kalzumeus.com编辑精选
程序员对姓名的错误假设
Falsehoods Programmers Believe About Names
2010 — 2021,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是程序员 Patrick McKenzie(kalzumeus)的一篇著名文章,逐条列出程序员对"姓名"抱有的错误假设:以为每个人都有名和姓、姓名唯一、可由空格拆分、字符集仅限 ASCII、长度有限、姓名不会变等等。文章用大量真实反例说明真实世界的姓名远比数据模型复杂,强行规范只会让用户受挫。
为什么经久不衰:姓名建模的坑横跨所有文化与年代,每次有系统因撇号、多姓或单名把用户挡在门外,这篇文章就会被重新翻出来,至今仍是设计表单前的必读清单。
HN 评论精选
以自身遭遇说明政府表单的姓名假设会把父亲名字写错,主张姓名就是字符串、特殊情况交给人工。
这几乎和地址问题一样糟。我日常用中间名,父母好心地给我起了和父亲一样的名字乃至中间名缩写,多年来让无数征信机构困惑不已。可印第安纳州的出生证明系统却不可覆盖地假设:(1) 有孩子的人一定有名,(2) 名里不能有空格,(3) 中间名无关紧要。于是我孩子的出生证明上,父亲写成了我父亲的名字。可我只是个家长,哪有资格说自己叫什么?现实世界充满有机的细节,软件系统难以甚至无法完整捕捉。姓名就该只是一个字符串;排序或"亲爱的某某先生"这类称呼需求,应该用启发式加人工介入来处理。一百年前这些事都是人工逐件做的,如果你的商业假设是不能没有人工还得便宜,那也许该重新想想。否则你只会惹恼每一个名字不符合你任意规则的客户。
Vivtek查看英文原文
This is almost as bad as the address question. I go by my middle name (my parents thoughtfully gave me my father's first name and even middle initial, which has caused no end of confusion for many a credit bureau over the years). Unfortunately, the State of Indiana's birth certificate system assumes beyond any possibility of override that (1) everybody with children has a first name, (2) that first name has no spaces in it, and (3) the middle name is insignificant. So my kids' birth certificates have my dad's names on them as the father. But hey, who am I, a mere parent, to say what my name is? The real world is full of organic detail that is difficult or perhaps impossible to capture in full in a software system. A name should be just a string. If there are business requirements for sorting or name-of-address (e.g. "Dear Mr. Jones") they should be done with heuristics, with human intervention invoked in sticky situations if necessary. Sure, it's difficult, but you know, a hundred years ago that stuff was all done on an individual case-by-case basis by human beings; if your business assumption is that it can't be done cheaply enough without eliminating human intervention, perhaps you should rethink your assumptions. Otherwise, let me assure you you're irritating every customer whose name doesn't meet your arbitrary rules - in exactly the same way that Google pisses off everybody who needs human support. Everybody thinks that sucks. So at least you should get people's names right, using human intervention if you have to. (And addresses, too, but we just had an extended thread about that, like last month.)
巴西移民讲述多姓、双名在各类美国系统里被反复拒绝或错误拆分。
我是巴西人,我们国家绝大多数人至少有两个姓(通常一个母姓一个父姓),用空格分隔。我移民到美国,这里习惯只有一个姓,多个姓则用连字符。更麻烦的是我在法律上有两个名(第二个在官方文件里不算中间名)。有的系统不接受我的多个姓,我只能合并或用连字符;有的不接受双名;考华盛顿州驾照时系统接受了,但生成证号时出错,只能人工按逻辑录入。有的系统让你填完整法定姓名再自作聪明地拆分,结果我的第一个姓被登记成中间名且无法修改。好在快能申请入籍了,到时索性改名简化。
cblum查看英文原文
Tell me about it. I'm Brazilian, a country where the vast majority of people will have at least two last names (typically one maternal, one paternal, but not uncommonly multiple from either or both parents), separated by spaces. I've immigrated to the US, where the standard is for people to have a single last name, or if they have multiple, they're separated by hyphens. To make my situation a little worse, legally I have two first names i.e. the second one is not registered as a middle name in any official document I have. I've dealt with systems that wouldn't accept my last names. I either had to join them together, or separate them by a hyphen. Some systems don't accept my legal double first name. When I got my driver's license in WA, the system accepted it but later had trouble generating the license identifier, so they had to manually apply the system's logic and enter it by hand. Some systems just ask you to enter your full legal name, and then try to be smart about figuring out what your first, middle, and last names are. So I end up with the first of my last names being registered as a middle name, and I can't edit it. Fortunately I'm close to being able to apply for naturalization, and that'll give me the opportunity to change my name. I'll just drop part of my first name and one of my last names and finally make it simple. Edit: another thing that's funny wrt names in my life is my family situation. My wife has her own two last names (it's not super common in Brazil for women to take their husband's last name), and she has a daughter from her first marriage. So we all have totally different last names, with only my wife and my stepdaughter sharing one of their last names. That caused us a little bit of trouble crossing the border to Canada once.
因为撇号被无数系统拒绝,作者干脆在所有网站使用去掉撇号的"假"姓。
我已经不用真名了。我的姓里有撇号,被网站拒绝然后逼我重填所有信息的次数多到烦。现在干脆去掉撇号。高中时学生证印得乱七八糟:姓的前半段、姓的首字母、中间名、名。最后他们用引号代替撇号,机器居然就没事了。酒店的 wifi 系统如果要求输姓才能连也会崩,又在训练我用"假"姓订房。现在每次写姓我都会想"这系统会不会崩",于是倾向于永远不用正确拼写,免得以后对不上。年纪越大、生活里的系统越多,我越得给假名字。纸质记录上是真名,但数字记录里最终会变成什么呢?
staticassertion查看英文原文
I've stopped using my real name. My last name has an apostraphe, and at this point I'm just sick of websites rejecting it and then forcing me to refill in all of my information. So, now I drop the apostraphe. In high school my school ID was completely broken. It printed <first half of last name> <first letter of last name> <middle name> <first name>. They ended up putting a quotation mark instead of the apostraphe - somehow the machine handled that fine. That was the workaround. Hotel wifi systems tend to break if they ask for a last name to connect. Again, training me to reserve the hotel under a 'fake' last name. I actually notice it every time I write my last name. I'm like "is this a system that will break" and now I'm inclined to just never use the "real" spelling because then I'll get a mismatch later on. This is something I've really noticed over the last decade. The older I get, and the more systems become a part of my life, the more systems I have to give a fake name. Paper records will show my true name, but I wonder if at this point, given digital records, what it would appear to be.
务实的折中方案:一个原样显示的 UTF-8 字段,别自作聪明拆解。
我最近做的注册系统里,只有一个最大长度的 UTF-8 字段叫 Name。除了个人资料页和邮件模板里原样显示外,它不参与任何界面逻辑。它可能不完美,但在不成为姓名专家的前提下,这已经是你能做到的最好程度了。完整的本地化留给养得起专职团队的公司吧。
partyboat1586查看英文原文
The last sign-up system I built you get a single max length utf8 field called 'Name'. This field is not used at all in the UI except on the profile screen where it appears in full and in email templates where it also appears in full. It might not be perfect but it's as good as you are going to get without having to become an expert in names. I'll leave full localisation to companies that can afford to dedicate a team to it.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选