CodeSOD: Get My Switch

This post was originally published on this site

The Daily WTF

You know how it is. The team is swamped, so you’ve pulled on some junior devs, given them the bare minimum of mentorship, and then turned them loose. Oh, sure, there are code reviews, but it’s like, you just glance at it, because you’re already so far behind on your own development tasks and you’re sure it’s fine.

And then months later, if you’re like Richard, the requirements have changed, and now you’ve got to revisit the junior’s TypeScript code to make some changes.

switch (false) { case (this.fooIsConfigured() === false && this.barIsConfigured() === false): this.contactAdministratorText = ‘Foo & Bar’; break; case this.fooIsConfigured(): this.contactAdministratorText = ‘Bar’; break; case this.barIsConfigured(): this.contactAdministratorText = ‘Foo’; break; }

We’ve seen more positive versions of this pattern before, where we switch on true. We’ve even seen the false version of this switch before.

What makes this one interesting, to me, is

To read the full article click on the 'post' link at the top.