Isn’t it strange how the former seems practical if you’ve spent all day working in React using conditional rendering?
If I walked into that piece of code, it would churn my brain for a while, and yet the same expressed as a ternary operation would make sense to me immediately.
If I were a new developer, only the latter would give me hope.
I think compact code is beautiful, but I prefer verbose code because it is quickly understood. There is a balance, and if I feel like compact is the way to go, I’ll balance with comments. In the case of a ternary operator, I explain it once per file so that a more junior developer will have a clue to cling to.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.