Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Improve the use of Option and Try #243

Open
EzequielPostan opened this issue May 10, 2018 · 0 comments
Open

Improve the use of Option and Try #243

EzequielPostan opened this issue May 10, 2018 · 0 comments

Comments

@EzequielPostan
Copy link
Contributor

As discussed in #242 it would be good to follow the following approach to improve the way we use Option and Try types and reduce/remove the use of unsafe methods as .get if possible.

Approach

  1. If we expect a method parameter not to be optional, then we should try not to use an Option/Try as parameter type. This would lead to the client to handle the lack of necessary information before calling the method.
  2. If a method should receive this kind of optional values and depends on them to be successful (Some/Success) and can't provide a value of type A to handle failure cases, then one should return to the client an Option[A]/Try[A] instead of A. It should then be the client the one to either again solve the issue or forward the returned Option/Try.

Other approaches are welcome to this discussion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant