Sunday, August 19, 2012

Basic for all programing

Every book I read always give the reader how author programing style! In fact the reader have their own style to programing. Actualy the basic from all programing is how you make the script you can understand. Some programer understand to read other script (that's not created by him), other need time to understand the code before know how to used it.

This is not about how you make the code right or false. Actualy there is no code are wrong. There is an incorect code and logic. Is not simple to fix the incorect logic, but with good style and understanding your own code, we can fix it.
When I requested to become teacher from PHP code, I try to avoid give the student my style. The first things I should teach was why the style to be like that. for example:
if your gender are female, show female or show male
in PHP code you can type this
$gender=='F'?echo 'Female':echo 'Male';
or
if($gender=='F')
echo 'Female';
else
echo 'Male';
or
if($gender=='F'){
echo 'Female';
}else{
echo 'Male';
}
all code are true, but the style are different. Basicly the important from all code you make is the note! If you type a long code but you don't give a note for what the code for.. Is not good, the reason if you found error (on logic), you can fix it more fast.

In the end, I hope you can make script like this

/* CHECK GENDER */
if($gender=='F')
{

echo 'Female';
}else{
echo 'Male';
}
/*END CHECK GENDER*/
include with notes.
but you need to focus on your own style. If you don't have the style.. Mimic other, but remember to give notes. Is better leave a notes on you code to debug you script in the future.

0 comments: