views:

45

answers:

2

Hi,

I have a web app, I'd like the user to supply their real name, for friend searches. I'm not sure whether to store this as two separate fields in my user class, or as a single field:

class User {
    @Persistent
    private String mFirstName;

    @Persistent
    private String mLastName;
}

    .. or ..

class User {
    @Persistent
    private String mFullName;
}

I'm only going to use it to let users search for people. For example, they might search for "John", or "John Doe", or "Doe". I'm not sure what the app engine query engine allows us to do here, in terms of partial matches and such - has anyone gone through this and can recommend a good solution? I'm leaning towards just storing the full name to make searches easier,

Thanks

+1  A: 

Short answer: store a full name.

Long answer here (Falsehoods programmers believe about names, by Patrick McKenzie).

I’m going to list assumptions your systems probably make about names. All of these assumptions are wrong.

  • (#1) People have exactly one canonical full name.
  • (#20) People have last names, family names, or anything else which is shared by folks recognized as their relatives.
Emilio Silva
That link doesn't provide any answers, just a bunch of potential problems with no guidance on where or how often they appear. Most of them are thought provoking, but not all are actually valid problems for every application.
Peter Recore
In the discussion, this point comes up and I agree. But, as a foreigner living in the US, I had to cripple my name in several inconsistent ways to fit First-Last or First-MI-Last fields. Having a Full Name field would be enough for most people.
Emilio Silva
+2  A: 

It's not just a question of how you end up storing names, it also matters how you ask for names on your web form.

Prompting with just a single field guarantees you'll see all the various unparsed forms listed here, and many more.

If you prompt with a first and last field, the vast majority of inputs will probably conform, but you'll still have many exceptions (prefixes, middle names, suffixes, punctuation, etc).

If you clearly prompt with separate prefix, first name, middle name, last name, suffix fields, there'll be even fewer exceptions, but users might get peeved or confused.

You might even offer both: an easy one-field input or preparsed multifield input. Explore what other web sites do and see if you find them appealing/confusing/whatever.

Also keep in mind that if you input separate fields you can always easily join them later, but if you input only a single field you won't have the typist's help if you need to parse it later.

joe snyder