3 ms·
> Explicitly declare the return type of all public methods. +1 This is very helpful for quickly scanning code. >Again, IMHO, while Option is an exceptionally
by runT1ME 11y ago
> Explicitly declare the return type of all public methods.
+1
This is very helpful for quickly scanning code.
>Again, IMHO, while Option is an exceptionally useful type, when indicating errors at the "public API level" it proves to be insufficient.
Agreed. Either, or even better, \/ (Scalaz either/disjunction) is much easier to work with and more expressive.
- AdieuToLogic 11y ago> >Again, IMHO, while Option is an exceptionally useful type, when indicating errors at the "public API level" it proves to be insufficient. > Agreed. Either, or even better, \/ (Scalaz either/disjunction) is much easier to work with and more expressive. I, too, recommend using the Scalaz \/[0] Either type as it is "right leaning" and lends itself quite nicely to processing due to it being both a model of Bifunctor[1] (making handling either a success or failure situation quite clean) and contributing nicely to defining an EitherT monad transformer capable of abstracting both latency (the Future part) and errors (the \/ part). For example, I often have the following defined in projects: type FutureEither[+T] = EitherT[Future, DomainError, T] Where "DomainError" is a top-level type representing an error encountered during processing. All this adds up to being able to work with "happy path" logic, deferring error handling until it can be handled/reported and network request/response latency absorbed until it becomes an error (addressed as any other error would be). 0 - https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/Either.scala https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/... 1 - https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/Bifunctor.scala https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/...