Andrei Dascalu
1 min readJun 21, 2020

--

YEah ... no.

Also the examples given are wrong to the core.

if (something) throw Eception

else ...

wtf? In what universe / language do you need an else after a throw? If the code moves forward following the throw, you need (at most) another if, but no else.

Yeah, you never need an else and there's no need of an else even in your example, but the solution is to simply delete them and (maybe) keep the if's unless you're breaking the S in SOLID.

Replace 3 if's with a state machine is premature optimisation (oh, maybe one day we will need more ... sure).

--

--