Functional Aspects: They Say Stay Away From Ternary

I remember myself working on a project where ternary operators were used very actively in various situations. The more I read that code, the less comfortable I felt with it, and eventually caught myself on these questions:

  • Why are there so many cases of this syntax construct.
  • Should I (am I expected to) use the ternaries as well for the consistency reasons?
  • Is this code good or not generally speaking?
  • And more importantly, whether I should use ternaries a lot or stay away from them?

The more developers I spoke with, the more diverse perspective I heard. Eventually, I got very confused and made a decision to not use the weird thing (due to the absence of a good framework or a “mental model”). The decision has been followed almost to a degree it becomes a mantra but…

Continue reading →