Hello. I have a question that spining around my head for a long time. I
prefer to make this kind of if statement:
if (!$GLOBALS['phpgw_info']['user']['admin']) Header(
'Location: '.$GLOBALS['phpgw']->
link('/', 'menuaction=for um.uiforum.inde x')
);
But almost all the 'good' php code I saw write it this way:
if (!$GLOBALS['phpgw_info']['user']['admin'])
{
Header(
'Location: '.$GLOBALS['phpgw']->
link('/', 'menuaction=for um.uiforum.inde x')
);
}
the argument is the latter is more readable and easy to understand. But,
to me, a if statement immediately followed by another statement or
function call is more readable and easy to understand. It saved me from
thinking what's after this statement or function call. Truly, I think
keeping a stack of 'if' or 'for' in the brain is difficult for me, I
tends to remove the {} and add the statement after if-clause when if
statement contain only one statement.
I am just thinking if my way of keeping code logic in brain is too
wired. If most people truly consider the {} more easier to
read/understand, I'll force myself write understandable code; if there
are only very small difference in understanding (considering reading
10000 line of source, even small difficulty counts), I would like to
keep my style.
prefer to make this kind of if statement:
if (!$GLOBALS['phpgw_info']['user']['admin']) Header(
'Location: '.$GLOBALS['phpgw']->
link('/', 'menuaction=for um.uiforum.inde x')
);
But almost all the 'good' php code I saw write it this way:
if (!$GLOBALS['phpgw_info']['user']['admin'])
{
Header(
'Location: '.$GLOBALS['phpgw']->
link('/', 'menuaction=for um.uiforum.inde x')
);
}
the argument is the latter is more readable and easy to understand. But,
to me, a if statement immediately followed by another statement or
function call is more readable and easy to understand. It saved me from
thinking what's after this statement or function call. Truly, I think
keeping a stack of 'if' or 'for' in the brain is difficult for me, I
tends to remove the {} and add the statement after if-clause when if
statement contain only one statement.
I am just thinking if my way of keeping code logic in brain is too
wired. If most people truly consider the {} more easier to
read/understand, I'll force myself write understandable code; if there
are only very small difference in understanding (considering reading
10000 line of source, even small difficulty counts), I would like to
keep my style.
Comment