Here are next ideas how to replace “if” statement by other patterns.
Improvement of loop
Each loop checks condition if the next iteration should be performed. You should use this construction instead of using if(..) break; inside the loop if it’s possible.
if statement is often used in almost every code. Unfortunately it reduces readability of source code and may influences of performance (but rather in low level programming languages). Below I show examples of
if and propositions of improvements.
Often there’s need to change variable or return value depending on some condition. Instead of if/else it’s better to use conditional operator:
I started to rewrite Thot form PHP to Java. The reason is that it will not be no longer installed on the same server as website, but will work as a service. Only small plugin will be installed in CMS to communicate with the service. The need of install Thot for each website was one of the biggest problem of the first version. More…