Common pitfalls of developers
Logic operators
One of the most common pitfalls to any developers because we all think that we are good with that, and there is no way we do it wrong. Unfortunately, that is where thing is bad, we unconsciously think that it is correct while it is the opposite.
Take a look at this case. The developer wants check if current shop that is NOT one specific shop, and the customer is
not on the cart page (Mostly he wants to skip this shop from having the checkout button disabled). If it is, early
breaks,
there is no need to
prevent the checkout
button from being
clicked.
However, using a
||
operator here is wrong since if either part of the condition is true, then it hits the early break (Any shop is
not MULTIPLE_ONLINE_SHOP or not on the Cart page, it hits early break almost everytime). So if you have two negative
operators along with an early break, beware to double consider whether you are using it wrong.