I am quite confused about this subject, let’s say I have a Authentication class (logging in, logging out, checking if logged in or not)
A User class (that holds a User, getters, setters, save etc)
Where should I put stuff like creating a User, and like validating a Username? A new class, like “UserManager” or something?
This is more of a design question, which makes it a little difficult to answer since there probably isn’t an objectively right way to do this. Rather, several people have created several different solutions that all work equally well.
One suggestion would be to create a
Users(plural) class that has public methods likeaddNew(returnsUserobject) anduserExists(returnsBool), as well asvalidateUsername(also returningBool).This
Usersclass could contain additional logic used to managing your user-base as a whole.