Tips

My personal tips and notes I collected for myself along my journey of being better developer

Don’t not not

Don’t not not

Reading Time: 1 minute

Please (PLEASE!) don’t use the following patterns for naming your variables or functions:

let not_logged_in or func is_not_admin() or $isNotAvailiable.

That’s because when one reads your code he/she has to interpret the login when there is a condition on the negative of those variables/function.

For example:

if not not_logged_in {
    /* if im not not logged in, then i am logged in */
}
....
$service = !$isNotAvailiable ? $a.service : null; // mind blown
...
etc.

Instead you can just remove the NOT word from naming, that’s much more readable and fluent.