The Example of Bad Codes

if (section = 'open') {
/*
* up to 100 or more lines of code
*/
} else if (section = 'closed') {
/*
* up to 100 or more lines of code
*/
} else if (section = 'delayed') {
/*
* up to 100 or more lines of code
*/
} else {
/*
* up to 100 or more lines of code
*/
}


Actually when you see something like the codes above, you should change it into:

if (section = 'open') {
doSomethingForOpenSection();
} else if (section = 'closed') {
doSomethingForClosedSection();
} else if (section = 'delayed') {
doSomethingForDelayedSection();
} else {
doSomethingForUnexpectedSection();
}

And the world will become more beautiful!!

1 comments: (+add yours?)

Macarons Recipes said...

Hi great reading youur blog