3 ms·
Even accepting the dubious premise that "pretty text = maintainable code", he's juked his exampled by (i) littering the simple early-outs with unnecessary "else
by mwkaufma 6y ago
Even accepting the dubious premise that "pretty text = maintainable code", he's juked his exampled by (i) littering the simple early-outs with unnecessary "else"s and (ii) stripping the "break"s from his switch.
- seanbarry 6y agoAuthor here. I don't think "pretty text = maintainable code". I acknowledge in my article that this pattern would be polarising (but underestimated quite how much so!). It's a pattern that IMO has a place. I personally find it more readable than multiple if blocks - but from reading the comments this seems to be very much down to personal taste. It's not a pattern that should be used in all cases by any means. You're right about the unnecessary elses - in hindsight I wish I'd put a bit more time in to the examples I used. As for the breaks, you don't need a `break` when you're returning or throwing an error in a switch case. If I had included these, someone else would have commented that they aren't needed ¯\_(ツ)_/¯