Question

For example, I have a password generator in my user registration website. Where should I put the function of generating password? Put together with UserController?

What is the correct way to put these functions?

Était-ce utile?

La solution

I would recommend putting it into a class of its own. For the sake of SRP, your UserModel should do things with a User and only a User. Your UserModel class should not be responsible for generating passwords for new users. Separate it into its own class and call a method on that class during the creation of your new user in your UserModel.

Autres conseils

I would put it in my User Model.

Or you could create a Utility class and put it in there.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top