Further shortening of your code (Part 2)

May 17th, 2008 | by Avatar |

As stated in the previous entry, shortening or simplifying your source code makes it easier and better when you need to find bugs and a good example of this would be :

Example :
if ($Mickey == true) echo ‘Welcome to the Mickey Mouse Club House’;
elseif ($MainCharacter == false) echo ‘Hi Barney!’;

Making things a bit simpler, say by taking away the ‘==’ and ‘!=’ gives you;

if ($Mickey) echo ‘Welcome to the Mickey Mouse Club House.’;
elseif (!$MainCharacter) echo ‘Hi Barney!’;

Simplifying code should be the aim of each and every programmer (who’s head aches when you get some bugs you got to fix) so you get to code less and better than the other guy. Remember, we’re all on the same plane using the same free language so we should be helping others for the better.

Sorry, comments for this entry are closed at this time.