Παλιότερα ακολουθούσα κι εγώ τα conventions σε αυτό το θέμα (γιαυτό μου έχει μείνει και πότε πότε βάζω και τώρα).The Punisher wrote:τα conventions λένε ότι πάντα βάζουμε braces .. και συμφωνώ κι εγώ!Μα σε περιπτώσεις που ο κώδικας μέσα στο block είναι μόνο μια γραμμή, δεν χρειάζονται καν braces
Τελικά διαπίστωσα ότι συνήθως βολεύει περισσότερο να μην υπάρχουν braces σε αυτές τις περιπτώσεις, ειδικά όταν μαζεύονται πολλά παρόμοια blocks κώδικα.
Πχ, τι είναι πιο ευανάγνωστο, αυτό που είναι όλα στοιχισμένα και βλέπεις κατευθείαν τα μεταβλητά μέρη (και τα return temp στοιχισμένα είναι στην πραγματικότητα, εδώ δεν ξέρω γιατί βγαίνουν έτσι):
Code: Select all
if(chooseSyllable(4) && (temp = accentuateWordEnd(word, "σμού"))) return temp;
if(chooseSyllable(5) && (temp = accentuateWordEnd(word, "τούν"))) return temp;
if(chooseSyllable(7) && (temp = accentuateWordEnd(word, "είο"))) return temp;
if(chooseSyllable(8) && (temp = accentuateWordEnd(word, "τώ"))) return temp;
if(chooseSyllable(8) && (temp = accentuateWordEnd(word, "ινώ"))) return temp;
if(chooseSyllable(11) && (temp = accentuateWordEnd(word, "ένε"))) return temp;
if(chooseSyllable(12) && (temp = accentuateWordEnd(word, "ική"))) return temp;
if(chooseSyllable(12) && (temp = accentuateWordEnd(word, "ικής"))) return temp;
if(chooseSyllable(16) && (temp = accentuateWordEnd(word, "κό"))) return temp;
if(chooseSyllable(16) && (temp = accentuateWordEnd(word, "μένη"))) return temp;
if(chooseSyllable(16) && (temp = accentuateWordEnd(word, "ικού"))) return temp;
if(chooseSyllable(17) && (temp = accentuateWordEnd(word, "κή"))) return temp;
if(chooseSyllable(17) && (temp = accentuateWordEnd(word, "ένος"))) return temp;
if(chooseSyllable(17) && (temp = accentuateWordEnd(word, "ικά"))) return temp;
Code: Select all
if(chooseSyllable(4) && (temp = accentuateWordEnd(word, "σμού"))){
return temp;
}
if(chooseSyllable(5) && (temp = accentuateWordEnd(word, "τούν"))){
return temp;
}
if(chooseSyllable(7) && (temp = accentuateWordEnd(word, "είο"))){
return temp;
}
if(chooseSyllable(8) && (temp = accentuateWordEnd(word, "τώ"))){
return temp;
}
if(chooseSyllable(8) && (temp = accentuateWordEnd(word, "ινώ"))){
return temp;
}
if(chooseSyllable(11) && (temp = accentuateWordEnd(word, "ένε"))){
return temp;
}
if(chooseSyllable(12) && (temp = accentuateWordEnd(word, "ική"))){
return temp;
}
if(chooseSyllable(12) && (temp = accentuateWordEnd(word, "ικής"))){
return temp;
}
if(chooseSyllable(16) && (temp = accentuateWordEnd(word, "κό"))){
return temp;
}
if(chooseSyllable(16) && (temp = accentuateWordEnd(word, "μένη"))){
return temp;
}
if(chooseSyllable(16) && (temp = accentuateWordEnd(word, "ικού"))){
return temp;
}
if(chooseSyllable(17) && (temp = accentuateWordEnd(word, "κή"))){
return temp;
}
if(chooseSyllable(17) && (temp = accentuateWordEnd(word, "ένος"))){
return temp;
}
if(chooseSyllable(17) && (temp = accentuateWordEnd(word, "ικά"))){
return temp;
}
(ο κώδικας χρειάζεται γενικότερο σουλούπωμα, πέρα από coding style, αλλά ταιριάζει γάντι στο παράδειγμα οπότε I kinda feel happy που δεν τον έχω σουλουπώσει ακόμα )