Answer the question
In order to leave comments, you need to log in
Where is the best code quality?
With a colleague, an eternal holivar about the quality of the code.
Here is one example.
Please rate how it is correct to write in such pieces)
1)
if (!$_SESSION['isMobileOnly']) {
$opinionList = $dao->getOpinionList($bar['id']);
} else {
$opinionList = $dao->getOpinionList($bar['id'], 3);
}
$opinionList = $dao->getOpinionList($bar['id'], $_SESSION['isMobileOnly'] ? 3 : null);
Answer the question
In order to leave comments, you need to log in
Everything is bad
getMobileOpinionList()
getDefaultOpinionList()
$deviceCode = $_SESSION['isMobileOnly'] ? 3 : null;
$opinionList = $dao->getOpinionList($bar['id'], $deviceCode);
Wrap the session in an object, use types wherever possible.
See https://symfony.com/doc/current/components/http_fo...
ps Move the number 3 into a named constant.
In order of increasing entropy:
$opinionList = $dao->getOpinionList(
$bar['id'],
$_SESSION['isMobileOnly'] ? 3 : null
);
No one! What is the number 3, why is it not made into a constant, if it is so important. It's like you're only writing for yourself..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question