News for hackers. Stuff that matters.
Re:Guidelines for writing readable code by thecatspaw on Friday September 14, 2018 @09:05AM (#17986890)
you dont reduce nesting by moving all checks to the beginning, you reduce nesting by moving the contents into methods.

if (product.hasPrice){ if (someOtherCondition){ Cart cart = cartService.getCartForCurrentUser(); cartService.addToCart(product,1); } }

to

if(canSellProduct(product)){ addToCurrentCart(product) }

There are no comments on this comment yet.