Austin Danger Powers
-
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.
-
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.
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.
-
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.
I actually know two people with 5-letter initials (they each have double middle and double last names).
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 actually know two people with 5-letter initials (they each have double middle and double last names).
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.
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.
-
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.
Luc Pattyn wrote:
How about the code?
Ok, I'll construct the N-name control. The user can enter any number of name parts, and select (from a drop-down) the type each name part is. It will look a bit like this:
[First v] _________
[Middle v] _________
[Last v] _________
[Freak v] _________[Add Name Part]
Of course, there will be validation rules (e.g., last names cannot appear before first names). Happy now? :rolleyes:
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.
-
Luc Pattyn wrote:
How about the code?
Ok, I'll construct the N-name control. The user can enter any number of name parts, and select (from a drop-down) the type each name part is. It will look a bit like this:
[First v] _________
[Middle v] _________
[Last v] _________
[Freak v] _________[Add Name Part]
Of course, there will be validation rules (e.g., last names cannot appear before first names). Happy now? :rolleyes:
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.
-
Luc Pattyn wrote:
How about the code?
Ok, I'll construct the N-name control. The user can enter any number of name parts, and select (from a drop-down) the type each name part is. It will look a bit like this:
[First v] _________
[Middle v] _________
[Last v] _________
[Freak v] _________[Add Name Part]
Of course, there will be validation rules (e.g., last names cannot appear before first names). Happy now? :rolleyes:
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.
AspDotNetDev wrote:
Of course, there will be validation rules (e.g., last names cannot appear before first names). Happy now? :rolleyes:
No. In Bavaria, the "family name" (which is called the "last name" in English) comes first. Also Hungarians do it this way.
-
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.
-
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.
AspDotNetDev wrote:
Dim firstEmpty As String = String.IsNullOrEmpty(firstName)
String.IsNullOrEmpty returns "bool"... How are you assigning it to a string variable..? :confused:
-
AspDotNetDev wrote:
Dim firstEmpty As String = String.IsNullOrEmpty(firstName)
String.IsNullOrEmpty returns "bool"... How are you assigning it to a string variable..? :confused:
*grumbles* bloody VB *grumbles*
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.
-
*grumbles* bloody VB *grumbles*
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 had completely forgotten about
Option Strict On
; it's been years since I had the misfortune of writing in VB. Implicit conversions can be such a waste... At least it wasn't using loose variables. X| -
AspDotNetDev wrote:
Of course, there will be validation rules (e.g., last names cannot appear before first names). Happy now? :rolleyes:
No. In Bavaria, the "family name" (which is called the "last name" in English) comes first. Also Hungarians do it this way.
Then I'll add "Family Name" and "Given Name", and they will not have the same validation rules. :)
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 actually know two people with 5-letter initials (they each have double middle and double last names).
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.
AspDotNetDev wrote:
5-letter initials
In Spanish speaking Latin America (maybe all Spanish nations?) you have two last names - your father's first last name and your mother's first last name. When a woman marries, they add their husband's first last name on to their name (so my wife has five names, excluding the 'del' and 'de'). Our niece already has five names so when she marries she'll have six names!? You think this is strange but every time they ask for my surname they wait for me to say a second one and I have to explain to them I'm British and don't have a second one; they think I'm the crazy one!
-
*grumbles* bloody VB *grumbles*
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.
-
Blame VB? That's hardly fair. Crap code can be written in any language. I believe the above is more a reflection of the coder, not the language.
Sure it's fair. VB didn't show a compilation error. It is happy enough to do implicit conversions that the programmer didn't intend. Though, that can be turned off. Will have to remember to do that for all the VB projects at my company. I'm a little afraid of all the errors that will result. :~
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.
-
Sure it's fair. VB didn't show a compilation error. It is happy enough to do implicit conversions that the programmer didn't intend. Though, that can be turned off. Will have to remember to do that for all the VB projects at my company. I'm a little afraid of all the errors that will result. :~
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 agree 100% that implicit conversions should not be allowed. If there was no way of disabling that then VB would suck, but since that can be controlled then I'm still not clear on why VB is to blame? That's like blaming a car for being in an accident because the brakes didn't self-engage... the tools are there, blaming VB for not knowing how to use them just doesn't make sense to me. Besides - implicit conversion is not really the worst part of the function, is it?
-
I agree 100% that implicit conversions should not be allowed. If there was no way of disabling that then VB would suck, but since that can be controlled then I'm still not clear on why VB is to blame? That's like blaming a car for being in an accident because the brakes didn't self-engage... the tools are there, blaming VB for not knowing how to use them just doesn't make sense to me. Besides - implicit conversion is not really the worst part of the function, is it?
G-Tek wrote:
implicit conversion is not really the worst part of the function, is it?
That would get my vote for worst part. What part of the function would you vote worst part? Maybe we should suggest a Code Project survey. :rolleyes:
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 agree 100% that implicit conversions should not be allowed. If there was no way of disabling that then VB would suck, but since that can be controlled then I'm still not clear on why VB is to blame? That's like blaming a car for being in an accident because the brakes didn't self-engage... the tools are there, blaming VB for not knowing how to use them just doesn't make sense to me. Besides - implicit conversion is not really the worst part of the function, is it?
G-Tek wrote:
If there was no way of disabling that then VB would suck, but since that can be controlled then I'm still not clear on why VB is to blame?
The problem for me is that VB defaults to bad practices, just to make things "easy". That is why I see it as a "beginner" language, and prefer C#, C++, etc. It's not just VB though, I personally despise the loose variables that I've had to use in the past with languages such as PHP. No need to start a flame war over it, though. :cool:
-
I actually know two people with 5-letter initials (they each have double middle and double last names).
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 think it's very weird in some countries there is the culture of splitting First and Last names. Some web sites/places don't even have middle name field. I wonder why this is, here in Brazil it's always one field for the name only. Is there any need for splitting the names? I find it more confusing only. Worse for the websites that have only first and last names. Do I use: "Franco, Fábio dos Santos" or "dos Santos Franco, Fábio". Here everywhere, it's only one field for registering anywhere, field splitting were never missed.
-
G-Tek wrote:
If there was no way of disabling that then VB would suck, but since that can be controlled then I'm still not clear on why VB is to blame?
The problem for me is that VB defaults to bad practices, just to make things "easy". That is why I see it as a "beginner" language, and prefer C#, C++, etc. It's not just VB though, I personally despise the loose variables that I've had to use in the past with languages such as PHP. No need to start a flame war over it, though. :cool:
Maybe it would be ideal if they just forced everything to explicit (though I'm sure there would be a backlash from amateur developer who don't understand why so much of there code is suddenly broken). To be fair, I think the reason it is still in there as an option is for backward compatibility, keeping in mind VB has been around a long time. You are absolutely right - it shouldn't default to bad practices. It's been a while since I created a new VB project so I'm not even sure if it defaults to implicit or not. I know that any VB projects we have are all explicit. It gets way worse with VBA though - you have to declare "Option Explicit" in every new module. Heck, by default you're not even required to declare variables! How crazy scary is that?! No flame wars :-D I just have a tendency to defend VB because I find most of the complaints I see around it have less to do with the tool and more to do with the "tool" (ie. in many cases, amateur developer) that is using it. If we, as developers, choose to blame the tools we use for everything that goes wrong then we would have to likewise allow the people that use our applications to blame us, as the app developers, for everything that goes wrong in the app (and in my experience most of the issues are the user, not the app). I think we generally agree, but you simply come down harder on VB and maybe I'm too hard on the developer? That's my two cents!