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?


πŸ€“ The physical therapist who writes JavaScript πŸ’ͺ Web Developer 😎 Mentor 🧠 DPT πŸ˜„ SEO Expert 😁 React πŸ˜† Jamstack πŸ’¬ Ask me anything πŸ‘‰ DoctorDerek.com πŸ‘ˆ

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store