nus-cs2103-AY2122S2 / forum

14 stars 1 forks source link

? : Code Quality #131

Open Denniszedead opened 2 years ago

Denniszedead commented 2 years ago

Hi, is it recommended to use predicate ? ifTrue : ifFalse to improve code quality?

domlimm commented 2 years ago

Hello @Denniszedead ! I think ternary operators are more towards readability if you've just one simple condition that leads to either a true or false outcome. If there are more than the said outcome, it's better to use either if & else or switch statements. These are just my two cents!

damithc commented 2 years ago

Hi, is it recommended to use predicate ? ifTrue : ifFalse to improve code quality?

It is certainly allowed e.g., our coding standard does not object to its use. Does it increase code quality? Depends on the context.