Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

I would put it in my User Model.

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top