Is this just a matter of preferences….the code below I’m considering moving to serialized && statments…which is an effective if/else with embedded if/else ‘ s .
Is this a preference or is there a "best practice"?
function invoke()
{
$obj=new validate($this->_protected_arr);
if($obj->empty_user())
{
if($obj->email())
{
if($obj->pass())
{
if(self::validate())
{
self::activate_session();
$control=new controller_control();
$control->send('pass');
}
else
{
new view_message('validate');
}
}
else
{
new view_message('pass');
}
}
else
{
new view_message('email');
}
}
else
{
new view_message('empty');
}
}
Reverse your approach..
Your code path will only continue if it’s safe – this will avoid ugly nested joins and adds flexibility for refactoring. No need to && && && everything.