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?

Was it helpful?

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.

OTHER TIPS

I would put it in my User Model.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top