Avoid negative conditionals , clean code
JohnDivam

JohnDivam @johndivam

About: Focus on delivering high-quality solutions. #Laravel . Wye Team

Joined:
Jul 11, 2023

Avoid negative conditionals , clean code

Publish Date: Aug 22 '23
1 0

Avoid negative conditionals
Certainly! Writing clean and readable PHP code involves avoiding negative conditionals and using positive conditionals instead. Negative conditionals can make the code harder to understand and follow. Here's an example of how you can refactor code to avoid negative conditionals:

code with negative conditionals (Bad):

function isNotParent($node) : bool 
{

}
Enter fullscreen mode Exit fullscreen mode

code with positive conditionals (Good):

function isParent($node) : bool 
{

}
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment