Hi Miloš, yeah, as always the different approaches have different pros and cons. If the language supports it properly, though, I'm pretty confident in saying that using Result types is the better solution.

I only showed a really basic version of it – for better fleshed out ones you can look to rust or haskell.

And then exception translation isn't really harder – you just replace a try-catch with a map function.

Propagation will be made harder, because you're forced to do so explicitely. Since the Result type is monadic, it shouldn't be too hard to work with it (and in some languages it barely makes a difference), but it will result in a bit more code.

Personally, I prefer the explicit nature of result types, but I do also see that it will sometimes result in more complex code.

Oscar Ablinger
Oscar Ablinger

Written by Oscar Ablinger

Hi, I’m a Software Engineer that just writes on here about whatever he finds out in a given week. Could be scripts, insights or explanations of things I learned

No responses yet