I copied the answer from the 'bot. That didn’t pass. My question here is more about why repeating “split” several times which I think is unnecessary.
I know my solution won’t pass , it doesn’t meet the criteria. However, it does explain why I’m regularly adressed as Mr. Van, because this way of dealing with names doesn’t take into consideration last names with a space.
this shouldn’t at all be the way of dealing with names
about split(), it depends on the way you choose to structure it. this would need some brainstorming to make it DRY (don’t repeat yourself), but at the level at which this challenge is presented, I don’t think it needs that much work. for the setFullName method, it would be possible to use less split methods with just fullName = full.split(' ')
You are exactly right about your concerns. Often tutorials have a particular aim, and they provide simplifications of things for the purposes of having solutions that can be tested for. They shouldn’t be misconstrued as the basis for a real system. As a long time system architect who has done a lifetime worth of data modelling, there is a simple and common way to model the data for a person. The field naming does assume western conventions in terms of surname position, but it requires at least these separate columns:
Prefix (Mr. Mrs. Ms., Dr etc.)
Middle Name or Initial
Suffix (Jr. Sr. 3rd, etc.) [Optional, can be kept as part of Lastname]
So without a doubt these need to be kept as separate attributes, and can and should be used to compute a fullname in various forms.
Thanks for your input. and the funny links.
Don’t get me started om i18n. I just hate how, based on my IP adress’ location, I’m supposed to speak the local lingo. Why don’t they just look at at the browser’s language settings.
I have a db background too, and I’m always looking to restrict the users free input to an absolute minimum.
I have a Dutch name, so in your example I would use not prefix, but title, and prefix for the last name prefix (in my case -‘van’-, not capatalised).
Or maybe let it all go and give 'em 1 box in which they can put everything and forget about name-parts.
In terms of your suggestion, it absolutely makes sense for this particular challenge and you’re absolutely right. But you still have to write it in the way it passes the tests (regardless of how unrealistic this whole challenge is)
I hope my example didn’t lead to confusion. The prefix was a way of indicating how a person would formally be addressed, and is in no way part of the name. A person with a name like Richard Van Dyke would have: