Ch 7.6 of Code Complete 2 is confusing me, I've attached some sample code (in php) mind telling me which style is the best? or suggest something better? thanks
Style 1
public function register($user, $pass) {
if($this->model->isRegistered($user)
{
return false;
}
else if($this->twitter->login($user, $pass))
{
return $this->model->addUser($user, $pass);
}
return false;
}
Style 2
public function register($user, $pass) {
if($this->model->isRegistered($user)
{
return false;
}
$this->twitter->login($user, $pass);
if($this->twitter->isLoggedIn())
{
return $this-model->addUser($user, $pass);
}
return false;
}
Style 3
public function register($user, $pass) {
if($this->model->isRegistered($user)
{
return false;
}
$status = $this->twitter->login($user, $pass);
if($status)
{
return $this->model->addUser($user, $pass);
}
return false;
}
I'm currently making use of Style 1. Though I'm not quite sure if its the right one.