Cada vez que escribo una construcción típica de if-else en cualquier idioma, me pregunto cuál sería la mejor manera (en términos de legibilidad y visión general) para agregarle comentarios. Especialmente al comentar la cláusula else, los comentarios siempre se sienten fuera de lugar para mí. Digamos que tenemos una construcción como esta (los ejemplos están escritos en PHP):
if ($big == true) {
bigMagic();
} else {
smallMagic()
}
Podría comentarlo así:
// check, what kind of magic should happen
if ($big == true) {
// do some big magic stuff
bigMagic();
} else {
// small magic is enough
smallMagic()
}
o
// check, what kind of magic should happen
// do some big magic stuff
if ($big == true) {
bigMagic();
}
// small magic is enough
else {
smallMagic()
}
o
// check, what kind of magic should happen
// if: do some big magic stuff
// else: small magic is enough
if ($big == true) {
bigMagic();
} else {
smallMagic()
}
¿Cuáles son sus ejemplos de mejores prácticas para comentar esto?

else { // for future reader: sorry, at the moment of writing this I did not have time and skills to come up with a better way to express my logic