Organize your input checking and error reporting. Escape from too many inner if's

It's common to check some variables and report error / unsucceful operation if value is bad or to check result of operations before going forward. It can provide a bad code structure, where you can't find yourself in middle of a ton of bracets. Try to use return or exit instead, this will provide a cleaner, maintable code:function compute( $a , $b ) { if ( $a <= 5 ) { // outpu error return; } if ( $b >= 3 ) { // output error return; } // logic }As you can see, second solution is much more clear.


Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Homebrew uninstall