@Davio it’s an interesting discourse. There are pros and cons with regards to cognitive complexity, maintainability as well as domain modelling. Types and typed error handling, or rather context and domain boundaries are simply tools in your toolbox that, when utilized appropriately, can improve not only cognition, but also maintainability of a codebase and agility of teams.
I’ve recently wrote a comparative study on various errors handing strategies in Kotlin, their impact on maintainability, readability, as well as their pros and cons.
https://betterprogramming.pub/typed-error-handling-in-kotlin-11ff25882880
When you mentioned “it’s not more useful than e.g. runtime exception”, Sonar did show that cognitive complexity of exceptions are not exactly bad. However, as
@Ties rightly emphasized, the most painful was the lack types or rather undocumented behaviour. It really hurts when the codebase grows, especially when there isn’t a good technical leadership around domain modelling. We had a pretty sizeable service written in this style that we had to unfortunately rewrite due to maintainability issues.
In our company we have a large Kotlin gradle monorepo leveraging typed error handling approach. Having worked with large teams of varying experience, types and the simplicity that Arrow provides tremendously enhance our ability to deliver value with greater agility and confidence. It’s fascinating to listen to first time contributors having discussions about something along the lines of “oh i need to update my design, there’s a gap because we need handle these failure cases”