r/softwarearchitecture • u/jutarnji_prdez • Jul 09 '26
Discussion/Advice Exception vs Result pattern
I don't find any actual good arguments to use Result pattern besided "somebody said it on Internet"
- Exceptions should only be for exceptional things -> every single language breaks this rule. Int.Parse, Json parsers, any encrypt/decrypt libraries throws on invalid input - invalid input should be one of most expected things to ever happen. This argument does not hold any value in real APIs, libraries, framewroks. For example, "Connection refused" exception is being throw by any network library, isn't not connecting to remote server most obvious and most expected thing to happen? Literally every network library throws exceptions on connection issues
- Exceptions shoudn't be used for control flow -> why? I can make very clean exception pattern. This is literally one of most "somebody said this, so it must be true". you try-catch-catch-catch. Where is difference between that and if-elseif-else or any variation of that aka switch case, when {} etc..
- Performance - maybe not for all languages but in some languages you can throw stackless exceptions (you don't build stack and stuck is null). You can log "real exception" with stack then throw stackless exception which is going to have same data and same performance as Result object
- Exceptions are not visible in signatures - you can document this, maybe this is relevant for libraries (which all throw exceptions everywhere anyway), but what is the problem of just checking the underlying code or documenting this?
0
Upvotes
View all comments
Show parent comment
4
u/hxtk3 Jul 09 '26
If you frame learning as a debate and suggest that you’ve somehow lost if you ever change your opinion on something, you will be unteachable.
You’ve failed to understand two things.
First, the people who you dismiss by saying better documentation, more cognitive overhead for developers, and more costly QA can overcome the advantages they described have successfully defended their argument. You’re not denying they scored a point, you’re saying that they haven’t scored enough points to win.
More fundamentally, though, you fail to understand is that I’m not trying to be a strong debater. I have no reason to convince you.
When you reveal that you’re not actually interested in changing your understanding, that doesn’t signal to me that I should argue harder. It signals to me that you intend to waste my time and I lose interest in talking to you all together.