Austin Danger Powers
-
AspDotNetDev wrote:
companies can send you emails and address you by your first name
someString.Split(' ')[0];
AspDotNetDev wrote:
let the user know that all portions of the name must be entered
lblName.Text = "Full Name:"
I know that name splitting has it's usefulness, like displaying in formats like "Last, First Name" the way the user wants, but I believe single field names benefits outweighs by far the benefits of multiple field names. Not only on the functional perspective, but also on development. It's much simpler to have only one column on the database to hold a name. A better solution would indeed be a toggle, but then, that adds overhead to development.
How would your code handle a user who enters: "Mr. Fabio Franco, Ph.D."? :) Or how about these:
- "Mr Fabio Franco, Phd"
- "Mr Fabio Franco the first, phd cna"
- "Mrs. Fabio Franco"
- "Fabio Franco, Mr"
- "Fabio Franco III"
- "Fabio"
There is quite a bit of variation out there, and I'm sure more variation I don't know about in other cultures. Users do funny things when you let them (try to) think for themselves.
This is not the age of reason, this is the age of flummery, and the day of the devious approach. Reason’s gone into the backrooms where it works to devise means by which people can be induced to emote in the desired direction.
-
How would your code handle a user who enters: "Mr. Fabio Franco, Ph.D."? :) Or how about these:
- "Mr Fabio Franco, Phd"
- "Mr Fabio Franco the first, phd cna"
- "Mrs. Fabio Franco"
- "Fabio Franco, Mr"
- "Fabio Franco III"
- "Fabio"
There is quite a bit of variation out there, and I'm sure more variation I don't know about in other cultures. Users do funny things when you let them (try to) think for themselves.
This is not the age of reason, this is the age of flummery, and the day of the devious approach. Reason’s gone into the backrooms where it works to devise means by which people can be induced to emote in the desired direction.
I get what you mean, users thinking by themselves are not good :~, but I think design can solve those issues :) : Title: Full Name: Again, it works so well here that I'm still to find a place in .com.br domain that asks for a multi field name. I don't there's magic bullet for anything, but I still believe that my argument stands, that single field names benefits outweighs multi-field names. I think in US is more of a culture of "most do this way, so we're not changing", although I've seen several single field name cases already.
-
AspDotNetDev wrote:
I wasn't sure if I should put this in "Clever Code" or "Hall of Shame".
Hall of shame, definitely, specially considering that this line would do the same job:
Return String.Format("{0} {1} {2}", firstName, middleName, lastName).Replace(" ", " ").Trim()
Yes, it works even if firstName, middleName and/or lastName are null. Edit: Forgot the Replace
You missed the condition, that the middle name should be omitted if first or last is missing... :cool:
-
There is a small change in the specs, we now have two more optional (middle?) initials. Please adapt your code... :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Private Function GetFullName(firstName As String, middleName As String, lastName As String) As String
' Variables. Dim fullName As String Dim firstEmpty As String = String.IsNullOrEmpty(firstName) Dim middleEmpty As String = String.IsNullOrEmpty(middleName) Dim lastEmpty As String = String.IsNullOrEmpty(lastName) ' Combine name parts into full name. If firstEmpty Then If middleEmpty Then ' Powers. fullName = lastName Else If lastEmpty Then ' Danger. fullName = middleName Else ' Powers (ignore middle name). fullName = lastName End If End If Else If lastEmpty Then ' Austin (ignore middle name). fullName = firstName Else If middleEmpty Then ' Austin Powers. fullName = String.Format("{0} {1}", firstName, lastName) Else ' Austin Danger Powers. fullName = String.Format("{0} {1} {2}", firstName, middleName, lastName) End If End If End If ' Return full name. Return fullName
End Function
I wasn't sure if I should put this in "Clever Code" or "Hall of Shame". :)
This is not the age of reason, this is the age of flummery, and the day of the devious approach. Reason’s gone into the backrooms where it works to devise means by which people can be induced to emote in the desired direction.
wahaha this a "Hall of Shame" code indeed XD
-
There is a small change in the specs, we now have two more optional (middle?) initials. Please adapt your code... :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
You missed the condition, that the middle name should be omitted if first or last is missing... :cool:
Nope, if a middle name is all you have to call somebody, then you might as well call them that.
Chris Maunder wrote:
Fixign now.
But who's fixing the fixign?
-
Nope, if a middle name is all you have to call somebody, then you might as well call them that.
Chris Maunder wrote:
Fixign now.
But who's fixing the fixign?
What I meant was:
GetFullName(null, "middle", "last") => "last"
GetFullName("first", "middle", null) => "first"
isn't accomplished by your expression... but as well doesn't justify the code of horror in the OP -
What I meant was:
GetFullName(null, "middle", "last") => "last"
GetFullName("first", "middle", null) => "first"
isn't accomplished by your expression... but as well doesn't justify the code of horror in the OPActually, I am the OP and I didn't catch that. Take some 5's. :thumbsup:
Chris Maunder wrote:
Fixign now.
But who's fixing the fixign?
-
AspDotNetDev wrote:
Dim firstEmpty As String = String.IsNullOrEmpty(firstName)
String.IsNullOrEmpty returns "bool"... How are you assigning it to a string variable..? :confused:
Timothy CIAN wrote:
String.IsNullOrEmpty returns "bool"... How are you assigning it to a string variable..? :confused:
I was wondering the same thing - the line shouldn't compile (and doesn't, when I test it)!
-
Here it is pretty normal to have several "first names", in Dutch we actually call them firstnames (plural), although first, second, third, etc. would be more logical. I have four. So we don't really have a middle name or middle initial, when you ask me for a middle initial you'd get three of them. And all that is without double or composite names. How about the code? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
The multiple names is not SOOO uncommon here in the U.S.A. anymore either. The nanas were arguing about the middle name for our second daugher, so we just gave her "Amber Ann" as the middle name!