I am not sure whether there is a 'right' or 'wrong' answer to this one, but I was curious about the general consensus.
I have a User model that currently performs user functions (such as retrieving user details from the database, inserting new users to the database, updating user details etc.)
This leads to a fairly large class.
Is there any accepted thought on the breaking up of models, when the model already relates to one kind of entity? Or are large classes permissible in this case?
At the moment, the class will resemble something like this:
<?php
class Users_Model
{
public function userExists($user_id)
{
//Code to check if user exists
}
public function fetchUser($user_id)
{
//code to fetch User object from ID...
}
protected function fetchUserPassword($user_id)
{
return $this->fetchUserValue($user_id, "password");
}
protected function fetchUserLowercaseUsername($user_id)
{
return $this->fetchUserValue($user_id, "lower");
}
private function fetchUserValue($user_id, $value)
{
//fetch a user value from the database
}
public function logout()
{
//code to log user out
}
public function doesPasswordMatch($user_id, $password)
{
//checks if inputted password matches that which is on record...
}
public function createSession($user_id)
{
//creates sessions for DATABASE
}
private function createCookie($code, $user_id)
{
//create cookies for session
}
}
?>
My concern was doing too many things (it was performing retrieval of user information from the database, and handling the database side of logging out and sessions for the user).