r/shittyprogramming • u/calsosta • Nov 30 '18
Friday Code Confessions
If you have been living with technical debt and want absolution here is your opportunity.
Confess your sins and receive your penance.
155
Upvotes
View all comments
Show parent comment
1
u/[deleted] Dec 01 '18 edited Dec 01 '18
I would use a function with if statements and early exits. This ternary thing isn't very readable and it's hard to step through in a debugger.
It's very easy to reason about code like this and understand which tie you'll get depending on multiple factors.
It's also very easy to add new, or change existing rules. The same thing in ternary would not be pretty, especially if we also want another case where you do want to wear a tie if it's Christmas, but if it's not and you're wearing swim trunks, you don't want to wear a tie at all.