DEV Community

Discussion on: Code Smell 157 - Balance at 0

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

I was sure you handled that in your Impressive serie!

I completely agree with Use Exceptions just for unexpected situations and not for flow control because they are handy goto.

I go further than you though. By unexpected situations, I mean a programmer error (like your for each loop), or your VM going out of memory.

The network to fail on the other hand is a case that a programmer must totally expect. So I would use a Either<Failure, Success> to force him to always handle this case.

Obviously that works only in programming who supports lambdas and generics. If not fallback on the handy gotos.

Thread Thread
 
mcsee profile image
Maxi Contieri

can you elaborate on Either
is this some kind of flag boolean function ?

Thread Thread
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard

Going tomorrow on a trip, and short of time, but I've found a DEV article that sums it well