The Daily WTF
Follow
Representative Line: Terning White as a (Style)Sheet
Stefan's company faced a developer shortage years prior. They had a substantial helpdesk team, leading to an idea to retrain them for development. PHP was deemed easy to learn for this transition. Consequently, Stefan was assigned to manage code written by these newly trained developers. Much of this code contained redundant ternary operations, like assigning a background color based on a variable. In these instances, both conditional branches produced the exact same value. This was not a result of automated code generation. The variable involved, $tno, held a numeric value, not a boolean, and was never null. While it could be zero, representing a false condition, zero was just a regular value and not a special case. Therefore, the ternary operator was logically unnecessary and should have been removed entirely.