Good programming practices

Archive for April, 2011

Reduce usage of “if” statement, part 2

April 20th, 2011

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.
More…

Reduce usage of “if” statement, part 1

April 17th, 2011

The 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.

Conditional operator

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:
More…

Thot becomes a service

April 3rd, 2011

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…