One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
I have not read your complete series, but raising an exception is also an error for me :)
Throwing exceptions should only be done in exceptional cases where the reasonable thing to do is to crash.
The network not working on the other hand is just life and something to be dealt with.
So I would use a plein result type like all Either
Learn something new every day.
- I am a senior software engineer working in industry, teaching and writing on software design, SOLID principles, DDD and TDD.
Location
Buenos Aires
Education
Computer Science Degree at Universidad de Buenos Aires
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
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.
Learn something new every day.
- I am a senior software engineer working in industry, teaching and writing on software design, SOLID principles, DDD and TDD.
Location
Buenos Aires
Education
Computer Science Degree at Universidad de Buenos Aires
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
I have not read your complete series, but raising an exception is also an error for me :)
Throwing exceptions should only be done in exceptional cases where the reasonable thing to do is to crash.
The network not working on the other hand is just life and something to be dealt with.
So I would use a plein result type like all Either
Exceptions are for exceptional cases
The contrary is another smell
Code Smell 73 - Exceptions for Expected Cases
Maxi Contieri γ» May 31 '21 γ» 2 min read
but 'network not working' is an exceptional case that, IMHO, should be handled by the UI.
and return codes are not an option
Code Smell 72 - Return Codes
Maxi Contieri γ» May 28 '21 γ» 2 min read
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 arehandy 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.
can you elaborate on Either
is this some kind of flag boolean function ?
Going tomorrow on a trip, and short of time, but I've found a DEV article that sums it well
Error Handling with the Either type
MiloΕ‘ Ε ikiΔ γ» Mar 31 γ» 12 min read