mardi 21 novembre 2017

Clean code -- THE right practice

Sorry for my english, i just try to prove my point.

Why do standards say that IF statements have to be written like following:

if (a === b) { <-- starts with scope "name/statement"

} else { <-- Another scope with scope "name/statement" is added right after end of if scope.

}

and not like

if (a === b) { <-- starts with scope "name/statement"

}
else { <-- starts with scope "name/statement"

}

Second one seems more logical to me (and lots cleaner ofc)

When i want to seperate different logics i'll add new line between.

if () {

}
else {

}

if() {

}

Some references:

http://ift.tt/2AZRPuw

http://ift.tt/1hS9ViB

http://ift.tt/2fei8Fc

Aucun commentaire:

Enregistrer un commentaire