|
|
|
Is it just me, or this method:
public static MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status);
is not entirely conforming with the best practices?
(It's from the System.Web.Security standard .NET library)
Why can't it be:
public static MembershipUser CreateUser(MembershipUser userToCreate);
?
Pretty much all of the parameters are members of the MembershipUser class anyway.
Am I missing something in the software development trends?
modified 20-Oct-19 21:02pm.
|
|
|
|
|
Indeed - there is madness to your method
Actually - more seriously - nothing should get passed into a method that the method does not need and also..how are you going to create the userToCreate to pass to the Create...
|
|
|
|
|
Umm off the top of my head something like this?
MembershipUser userToCreate = new MembershipUser();
userToCreate.UserName =""blabla;
userToCreate.Password ="blabla";
...
//All the relevant stuff plus some validation...
..
userToCreate.providerUserKey=providerUserKey;
userToCreate = CreateUser(userToCreate);
this.Display(userToCreate.status);
...?
You have minimum parameters.
If you change your User parameters, you don't break every single possible reference etc etc.
Edit:
Actually, come to think of it, CreateUser shouldn't be in the Membership object altogether.
After populating the relevant properties, you could call:
userToCreate.Create();
which could call
userToCreate.Validate();
modified 20-Oct-19 21:02pm.
|
|
|
|
|
MembershipUser userToCreate = new MembershipUser()
{
UserName =""blabla
, Password ="blabla"
...
//All the relevant stuff plus some validation...
..
, providerUserKey=providerUserKey
}
Then you can write your own library method to do it if you like and hide the details, it's no big deal.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Yes - but Username[^] is read-only.
These changes would require it to be read-write which would lead people to try and change it after creation.
The pass-in-the-parameters create pattern is the best way to create something where some properties can only be meaningfully set in construction.
|
|
|
|
|
Duncan Edwards Jones wrote: The pass-in-the-parameters create pattern is the best way to create something
where some properties can only be meaningfully set in construction.
Exactly.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
"The pass-in-the-parameters create pattern" ???
Seriously, where did you see that?
Or maybe you are kidding right?
modified 20-Oct-19 21:02pm.
|
|
|
|
|
Best practices aren't.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
True, there are always 'better practices'.
Will Rogers never met me.
|
|
|
|
|
It appears to me they are still practicing...
Practice makes perfect.
|
|
|
|
|
Paul M Watt wrote: Practice makes perfect. I'm pretty sure that has never been proven.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
As I've been told... "Practice doesn't make perfect; perfect practice makes perfect".
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Somebody traded some E-Mails with me and got me to sign up on Intel's site.
Lots of clicks later, I found their XDK stuff and HTML 5.
Still not clear at all on precisely what it does, but it definitely does look like it's worth reading for a few days.
Is it worth the effort ?
Does it funnel your efforts towards their agenda ?
Is their agenda broad enough to encompass most real developers' ideas for creating their own apps and systems ?
Is anybody here already working with them ? Good ? Bad ? Ugly ? Smart ? Stupid ? Will I get rich in one week ?
|
|
|
|
|
C-P-User-3 wrote: Is anybody here already working with them ? Good ? Bad ? Ugly ? Smart ? Stupid ? Will I get rich in one week ? Why do you put a space between your last word and the question mark? I have seen several people do that. Are there schools or countries that teach you to do that? Is it intentional?
Inquiring minds want to know.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Quote: Is it intentional ?
FTFY
Only one hour to the next game
modified 16-Jun-14 17:00pm.
|
|
|
|
|
Yes, in several languages the question mark is separated from the last word with a space.
How is it important? ^^
There are two kinds of people in the world: those who separate humankind in two distinct categories, and those who don't.
"I have two hobbies: breasts." DSK
|
|
|
|
|
phil.o wrote: How is it important? Are you kidding?! It's critical. I can't read it with the spaces. I have no idea what it means. I wish codeproject had a translator that removed the spaces so I could read it all in American.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Well, you're a developper, aren't you? Shouldn't be so difficult for you to develop this SpaceCrusher.
As I really enjoy messy things, I won't do anything about that crucial problem :p
There are two kinds of people in the world: those who separate humankind in two distinct categories, and those who don't.
"I have two hobbies: breasts." DSK
|
|
|
|
|
Quote: developper
What's that, is it their job to remove white spaces in front of the question mark?
|
|
|
|
|
Not only! Exclamation marks are involved, too. That's twice the work.
There are two kinds of people in the world: those who separate humankind in two distinct categories, and those who don't.
"I have two hobbies: breasts." DSK
|
|
|
|
|
Being French you could go on strike for that ?
I know, its late...
|
|
|
|
|
Kenneth Haugland wrote: white sppaces FTFY
Signature construction in progress. Sorry for the inconvenience.
Damn you have the perfect signature - CBadger
|
|
|
|
|
I am a member of the society to upset RyanDev organization.
We are a division of the department of redundant nomenclature institute.
Our only weapon is distraction, and a space in front of a question mark.
Our TWO Weapons are distraction, and spaces in front of question marks.
Our tactics are frighteningly effective. See ? See ? See ?
Now,,,, send us your bank routing number and checking account number !!!
|
|
|
|