Melih Aksoy
1 min readOct 1, 2023

--

Thanks for reading and your feedback !

I'm not saying using Result, Either, Optional is useless in the article. They have their use.

I'm trying to explain how mixing monads is not a good practice. It increases code complexitiy and reduces readability and maintainability. Especially when business logic begins to intertwine. You end up with too many flatMaps ( which don't work the same for different containers ).

Result etc. containers are useful when you need to know about the operation state so you can recover or proceed. IMO there are usually handful of cases wher you actually need to recover and don't show a "retry" dialog ( or something).

I agree that it's easy to forget error handing. TBH it became a habit for me when I'm using coroutines. If I'm doing any flow operation, I just attach the`catch` block at the end if I want to do something explicit. Installing `CoroutineExceptionHandler` for the scope clears most of the error cases when it's not recoverable. PR reviews are also a good for spotting such cases.

--

--

Melih Aksoy
Melih Aksoy

Responses (2)