Dr. Derek Austin 🥳
1 min readJun 23, 2020

--

Hey Nicklas,

Thanks for sharing your opinion about if-else statements. I'm also a big fan of state machines.

I was confused as to what language this code was written in, so I checked the comments. Someone said it's C#. All those "internal override void" statements make me cringe, but I guess that's how you write C#.

Do you think there's a place for writing

if(yes) {}

if(!yes) {}

as a clearer alternatives to if-else?

I also think a lot of programmers are a fans of "guard clauses," which I understand to be early return statements:

if(yes) {return 1}

if(simonSays) {return 2}

return 3

Do I understand that correctly? Is that a pattern you like to use inside your state machines?

Cheers!

--

--

Dr. Derek Austin 🥳
Dr. Derek Austin 🥳

Written by Dr. Derek Austin 🥳

Hi, I'm Doctor Derek! I've been a professional web developer since 2005, and I love writing about programming with JavaScript, TypeScript, React, Next.js & Git.

Responses (2)