I'm not a huge fan of this pattern.
The idea of explicitly returning errors rather than throwing unchecked errors is great, but the proposed implementation is flawed - we need to always check the elements of the tuple before using the value to see if there is an error which will become error-prone rather quickly.
Fortunately, this is an already solved problem, known in other langues as Either or Result type, in which all of these ifs are abstracted away in form of map and flatMap / chain operations.
Potential implementation: gigobyte.github.io/purify/adts/Eit...
A skilled software engineer, talented problem-solver and team player with a passion for using technology to solve complex problems and constantly seeking out new challenges to advance my skills👨🏼💻
I'm not a huge fan of this pattern.
The idea of explicitly returning errors rather than throwing unchecked errors is great, but the proposed implementation is flawed - we need to always check the elements of the tuple before using the value to see if there is an error which will become error-prone rather quickly.
Fortunately, this is an already solved problem, known in other langues as
EitherorResulttype, in which all of theseifsare abstracted away in form ofmapandflatMap/chainoperations.Potential implementation: gigobyte.github.io/purify/adts/Eit...
Got your point. After all it's all about own preference.